Create API Token
POST
/api/v1/sectors/{sectorID}/tokens
const url = 'https://api.spartanauth.com/api/v1/sectors/example/tokens';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"name":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ” sectorID
required
string
Request Body
Section titled “Request Body ” Media type application/json
object
name
string
Example generated
{ "name": "example"}Responses
Section titled “ Responses ”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" }}default
Section titled “default ”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" } ]}