Skip to main content

Org API Tokens

Unit uses API Tokens to authenticate incoming requests. You can create API Tokens through Unit's Dashboard, or programmatically through an API call.

Suggestion

It is advisable that you read and understand the recommended way to use Unit's Authentication and Scopes before you create and use API tokens in your app.

Create Org API Token

Creates an Org API token.

VerbPOST
URLhttps://api.s.unit.sh/users/:userId/api-tokens
Data TypeapiToken
Timeout (Seconds)5

Attributes

description
string
A description of the Org API token.
scope
string
list of Scopes separated by spaces.
expiration
RFC3339 Date string
Expiration date of the Org API token.
sourceIpOptional
string
Optional. A comma separated list of IP addresses that are allowed to use the Org API token (no spaces allowed).
resourcesOptional
Optional. Restrict token to one or more specific resources. To one or many cards and/or to one or many accounts (cards under it, payments, transactions).
curl -X POST 'https://api.s.unit.sh/users/2/api-tokens'
-H 'Content-Type: application/vnd.api+json'
-H 'Authorization: Bearer ${TOKEN}'
--data-raw '{
"data": {
"type": "apiToken",
"attributes": {
"description": "Production token",
"scope": "customers applications",
"expiration": "2022-07-01T13:47:17.000Z"
}
}
}'

Response

Response is a JSON:API document.

201 Created

data
A The newly created resource.
Example Response:
{
"data": {
"id": "19",
"type": "apiToken",
"attributes": {
"createdAt": "2021-07-01T08:51:09.108Z",
"description": "Production token",
"expiration": "2022-07-01T13:47:17.000Z",
"token": "v2.public.eyJyb2xlIjoib3JnI..."
}
}
}

List

List Org API Token resources.

VerbGET
URLhttps://api.s.unit.sh/users/:userId/api-tokens
Timeout (Seconds)5
curl -X GET 'https://api.s.unit.sh/users/2/api-tokens' \
-H "Authorization: Bearer ${TOKEN}"

Response

Response is a JSON:API document.

200 OK

data
Array of APIToken
Array of org api token resources.
Example Response:
{
"data": [
{
"id": "21",
"type": "apiToken",
"attributes": {
"createdAt": "2021-07-01T09:13:23.211Z",
"description": "Production token",
"expiration": "2022-07-01T09:13:23.124Z"
}
},
{
"id": "22",
"type": "apiToken",
"attributes": {
"createdAt": "2021-07-01T09:14:10.590Z",
"description": "Testing token",
"expiration": "2021-07-01T13:47:17.000Z",
"sourceIp": "192.168.1.1,192.168.1.2"
}
}
]
}

Revoke

Revoke an Org API Token.

VerbDELETE
URLhttps://api.s.unit.sh/users/:userId/api-tokens/:tokenId
Timeout (Seconds)5

Response

Response is a JSON:API document.

200 OK

data
The requested resource after the operation was completed.
curl -X DELETE 'https://api.s.unit.sh/users/2/api-tokens/22'
-H 'Content-Type: application/vnd.api+json'
-H 'Authorization: Bearer ${TOKEN}'