# 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>
}
```

#### Dynamic QR Code

A Dynamic QR Code Token allows for the generation of receipts with unique identifiers, such as UUIDv4. This identifier is encoded into a QR code link, which is displayed for the customer on a customer-facing screen. By scanning this QR code with their mobile device, users can easily access and view their receipt.

```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": "DYNAMIC_QR_CODE",
        "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](https://docs.receipthero.io/filetypes/receipthero-json) as \<HeroJSON>

### Response OK

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