> For the complete documentation index, see [llms.txt](https://docs.thewalletcrew.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.thewalletcrew.io/developers-guides/scripting/extensions/aparte.md).

# Aparté scripts

Reference of the Aparté ticket mapper script, extensions.aparte.ticket.mapper: registration, the MapFromAparte and GetPassType handlers and an example.

The Aparté connector turns each Aparté ticket into a pass. The ticket mapper script adjusts that work in two optional ways: it adds computed values to the data the pass template reads, and it chooses a pass type for a ticket. This page is the reference for `extensions.aparte.ticket.mapper`. The connector itself is described on the [Aparté connector pages](https://docs.thewalletcrew.io/connectors/ticketing/aparte/advanced-customization.md); the rules shared by every connector script are in [Connector scripts](https://docs.thewalletcrew.io/developers-guides/scripting/extensions.md).

The Aparté API is read-only for tickets, so the mapping goes one way, from the ticket to the pass.

<details>

<summary><strong>Real-world examples</strong></summary>

* A venue sends tickets of the category "VIP" to a dedicated pass type and every other ticket to the connector's default pass type.
* An organizer adds a computed label, such as the entrance and the seat in one string, to the data of the pass.

</details>

## Registration

| Key                               | Slot file                 | Methods (required in **bold**) |
| --------------------------------- | ------------------------- | ------------------------------ |
| `extensions.aparte.ticket.mapper` | `aparte.ticket.mapper.js` | `MapFromAparte`, `GetPassType` |

The file sits in `server/scripts/`. The slot sits in the **Advanced** tab of the Aparté connector settings, and is read and written with `GET` and `PUT /api/{tenantId}/admin/extensions/aparte/scripts`. When no script is registered, the default mapping applies and the connector's default pass type is used. Installation tracking is built into the connector and needs no script.

```js
export default function (context) {
  context.register('extensions.aparte.ticket.mapper', {
    MapFromAparte: (ticket, entity) => {},
    GetPassType: async (ticket) => null
  });
}
```

## When it runs

`MapFromAparte` runs when the connector fills the pass data from a ticket, after the default mapping. `GetPassType` runs when a ticket pass's metadata is updated and the ticket is read again: a non-empty name replaces the pass type and the change is logged. At creation, the connector's **Default pass type** is used and `GetPassType` is not called. When the ticket cannot be read and **Invalid ticket pass type** is set, the pass switches to that pass type instead.

## Handlers

Both methods are optional: a method that is left out behaves as if it returned nothing.

| Method          | Parameters         | Returns                                     | Required | Sync or async                    |
| --------------- | ------------------ | ------------------------------------------- | -------- | -------------------------------- |
| `MapFromAparte` | `ticket`, `entity` | nothing                                     | Optional | Synchronous                      |
| `GetPassType`   | `ticket`           | a promise of a pass type name, or of `null` | Optional | Asynchronous: declare it `async` |

* `ticket` is the Aparté ticket. Its members are the PascalCase names of the Aparté ticket, for example `CategoryLabel`, `DoorLabel`, `Rank` and `Seat`. Its raw content is written on the pass data under `debug.aparte.ticket`, which shows the exact member names before writing the script.
* `entity` is the pass data, a flat dictionary (see [Data objects](https://docs.thewalletcrew.io/developers-guides/scripting/data-objects.md)). `MapFromAparte` adds keys to it and the pass template reads them.
* `GetPassType` returns the name of a pass type of the tenant, or `null` (or an empty string) to keep the current pass type.

## Errors and edge cases

* **No script registered**: the default mapping and the default pass type apply.
* **A method is missing**: it is skipped, as both are optional.
* **`GetPassType` returns a name that is not a pass type of the tenant**: the name is not checked and is set on the pass as is. Return only names of existing pass types.
* **`MapFromAparte` is declared `async`**: it is not awaited, so changes made after an `await` are lost.
* **A script throws**: the error is not caught. A throw in `MapFromAparte` fails the read of the ticket, and a throw in `GetPassType` fails the pass update.

## Example

Tickets whose category label is `VIP` go to the pass type `vip-ticket`. The script also adds a display label made of the door and the seat.

```js
function mapFromAparte(ticket, entity) {
  const door = ticket?.DoorLabel;
  const seat = ticket?.Seat;
  if (door && seat) {
    entity['ticket.access'] = `${door} - ${seat}`;
  }
}

async function getPassType(ticket) {
  if (ticket?.CategoryLabel === 'VIP') {
    return 'vip-ticket';
  }
  return null;
}

export default function (context) {
  context.register('extensions.aparte.ticket.mapper', {
    MapFromAparte: mapFromAparte,
    GetPassType: getPassType
  });
}
```

## Common pitfalls

* `GetPassType` is not declared `async`: the connector awaits a promise, so return one.
* A member name is typed from memory instead of being read in `debug.aparte.ticket`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.thewalletcrew.io/developers-guides/scripting/extensions/aparte.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
