Skip to content

Create API Token

POST
/api/v1/sectors/{sectorID}/tokens
curl --request POST \
--url https://api.spartanauth.com/api/v1/sectors/example/tokens \
--header 'Content-Type: application/json' \
--data '{ "name": "example" }'

Creates a new sector-scoped API token and returns the plaintext token exactly once along with its metadata. Requires a valid bearer token and sector-admin or default-sector-admin access.

sectorID
required
string
Media type application/json
object
name
string
Example generated
{
"name": "example"
}

A successful response.

Media type application/json
object
token
plaintext token — shown only once
string
apiToken
token metadata
object
id
string
name
string
sectorID
string
prefix
first 8 chars of the token for identification
string
createdAt
string format: int64
lastUsedAt
string format: int64
Example generated
{
"token": "example",
"apiToken": {
"id": "example",
"name": "example",
"sectorID": "example",
"prefix": "example",
"createdAt": "example",
"lastUsedAt": "example"
}
}

An unexpected error response.

Media type application/json
object
code
integer format: int32
message
string
details
Array<object>
object
@type
string
key
additional properties
Example generated
{
"code": 1,
"message": "example",
"details": [
{
"@type": "example"
}
]
}