# Token Receipt API

This API offers capabilities that extend beyond the standard Card Linking Receipt API, accommodating receipt delivery based on a variety of identifiers (tokens). It's essential to highlight that when using the Token Receipt API, receipts will consistently be delivered to users via the card linking solution when relevant. It is also possible to include several different tokens with a single request.

### **Examples**

#### Receipt Identifier

A Receipt Identifier Token facilitates the generation of uniquely identifiable receipts, using formats such as UUIDv4. These receipts can be distributed to end customers via methods like NFC, QR codes, or hyperlinks embedded in partner applications. Receipt identifiers must be unique within the scope of a single namespace.

```http
POST /api/v1/receipts/ HTTP/1.1
Host: api.dev.receipthero.io
Authorization: Token <RECEIPTHERO_API_KEY>
Content-Type: application/json

{
  "attributes": {
    "tokens": [
      {
        "type": "RECEIPT_ID",
        "value": "269654a1-7189-4c46-a9e7-44a29a78b442",
        "namespace": "partner-namespace",
      }
    ]
  },
  "receipt": <HEROJSON>
}
```

#### Card

Card Token is for Partners that are able to deliver card related token with receipt data.

```http
POST /api/v1/receipts/ HTTP/1.1
Host: api.dev.receipthero.io
Authorization: Token <RECEIPTHERO_API_KEY>
Content-Type: application/json

{
  "attributes": {
    "tokens": [
      {
        "type": "CARD",
        "value": "bmxpbmUgSldMjksImV4cCI6MTY0NzcwNTIyOSwiYXVkIjoid3d3",
        "id": "parter-token-xyz",
      }
    ]
  },
  "receipt": <HEROJSON>
}
```

#### Email

```http
POST /api/v1/receipts/ HTTP/1.1
Host: api.dev.receipthero.io
Authorization: Token <RECEIPTHERO_API_KEY>
Content-Type: application/json

{
  "attributes": {
    "tokens": [
      {
        "type": "EMAIL",
        "value": "john.smith@receipthero.io"
      }
    ]
  },
  "receipt": <HEROJSON>
}
```

#### User (OAuth2)

```http
POST /api/v1/receipts HTTP/1.1
Host: api.dev.receipthero.io
Authorization: Token <RECEIPTHERO_API_KEY>
Content-Type: application/json

{
  "attributes": {
    "tokens": [
      {
        "type": "USER",
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIiLCJpYXQiOjE2MzI4MTMzNjJ9.RNW59YOlWD_CZy3dLomd2SMC6-cGfkW-IuYVgodwb5I"
      }
    ]
  },
  "receipt": <HEROJSON>
}
```

### Token object

<table><thead><tr><th width="150">Key</th><th width="150">Type</th><th width="163.7142857142857">Description</th><th>Required</th></tr></thead><tbody><tr><td>type</td><td>String</td><td>Token type: DYNAMIC_QR_CODE|CARD|EMAIL|USER</td><td>✅</td></tr><tr><td>value</td><td>String</td><td>Token value</td><td>✅</td></tr><tr><td>id</td><td>String</td><td>Token identifier (Defined by the Partner)</td><td>Required when Token type = CARD</td></tr><tr><td>namespace</td><td>String</td><td>Partner namespace (defined by ReceiptHero)</td><td>Required when token type = DYNAMIC_QR_CODE</td></tr></tbody></table>

[ReceiptHero JSON](/filetypes/receipthero-json.md) as \<HeroJSON>

### Response OK

```http
HTTP 200 OK
Content-Type: application/json
```


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.receipthero.io/merchant-api-group/token-receipt-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
