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.

info

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

NameTypeDescription
descriptionstringA description of the Org API token.
scopestringlist of Scopes separated by spaces.
expirationRFC3339 Date stringExpiration date of the Org API token.
sourceIpstringOptional. A comma separated list of IP addresses that are allowed to use the Org API token (no spaces allowed).
resourcesArray of RestrictedResourceOptional. 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

FieldTypeDescription
dataAPITokenA 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

FieldTypeDescription
dataArray of APITokenArray 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

FieldTypeDescription
dataAPITokenThe requested resource after the operation was completed.
curl -X DELETE 'https://api.s.unit.sh/users/2/api-tokens/22' \
-H "Authorization: Bearer ${TOKEN}"