Post compressed tokens

To request a number of tokens for a number of digits of a preset alphabet, all of these values MUST be sent as data attributes together with the data type: tokens in the JSON request body. The data relationships payment data value in the JSON request body MUST contain the type: transaction, a valid transaction id according to the schema XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX and a valid payment intent ident according to the schema pi_XXXXXXXXXXXXXXXXXXXXXXXX.

The data attributes available value in the JSON response body shows the number of tokens that can be generated by the production line in general, just before the production starts. The data attributes size in the JSON request body determines the number of tokens to produce and SHOULD be smaller as, or equal to the number of available tokens. This number can be determined as described in the previous step and may be subject to further, non-technical restrictions. Any larger requested size is scaled down by the remote service to the reachable size.

The identifier of the new tokens object is returned from the remote service in the JSON response body as data id together with other attribute–value pairs. The remote service immediately starts producing the tokens.

Request endpoint

POST SERVER:PORT/api/tokens

Response status

201

Request headers

Accept:application/vnd.api+json
Content-Type:application/vnd.api+json
Session-Key:SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS

Response headers

Transfer-Encoding:chunked
Connection:keep-alive
Accept:application/vnd.api+json
Cache-Control:no-cache
Date:Tue, 19 Mar 2024 12:52:47 GMT
Content-Type:application/vnd.api+json
Server:nginx/1.25.4

Request body

{
    "data": {
        "attributes": {
            "size": "1000",
            "digits": "10",
            "alphabet": "UPPER_HEX"
        },
        "type": "tokens",
        "relationships": {
            "payment": {
                "data": {
                    "id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
                    "ident": "pi_XXXXXXXXXXXXXXXXXXXXXXXX",
                    "type": "transaction"
                }
            }
        }
    }
}

Response body

{
    "links": {
        "self": "/api/tokens",
        "info": "/api/tokens/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
    },
    "data": {
        "attributes": {
            "available": "1099511627776",
            "status": "requested",
            "analysis": "none",
            "size": "1000",
            "reachable": "100000",
            "alphabet": "UPPER_HEX",
            "timestamps": {
                "requested": "2024-03-19T12:52:47.637Z"
            },
            "digits": "10"
        },
        "id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
        "type": "tokens",
        "relationships": {
            "payment": {
                "data": {
                    "id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
                    "ident": "pi_XXXXXXXXXXXXXXXXXXXXXXXX",
                    "type": "transaction"
                }
            }
        }
    }
}

HTTPie example

$ http post SERVER:PORT/api/tokens Accept:application/vnd.api+json Content-Type:application/vnd.api+json Session-Key:SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS << JSON
{
    "data": {
        "attributes": {
            "size": "1000",
            "digits": "10",
            "alphabet": "UPPER_HEX"
        },
        "type": "tokens",
        "relationships": {
            "payment": {
                "data": {
                    "id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
                    "ident": "pi_XXXXXXXXXXXXXXXXXXXXXXXX",
                    "type": "transaction"
                }
            }
        }
    }
}
JSON