Create an API token
POST
/api/v1/account/tokens
const url = 'http://127.0.0.1:8080/api/v1/account/tokens';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"days":1,"libraries":["example"],"name":"example","nonexpiring":true,"scopes":["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 http://127.0.0.1:8080/api/v1/account/tokens \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "days": 1, "libraries": [ "example" ], "name": "example", "nonexpiring": true, "scopes": [ "example" ] }'The secret appears once in this response and cannot be retrieved again. Uses the persisted local-mode user when authentication is disabled. Otherwise an authenticated browser session is required, except for the current account and sign-in. Modifying authenticated requests require the current X-CSRF-Token. Credentials and responses must not be cached.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”X-CSRF-Token
string
Required with an authenticated browser session; read from current-account.
Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
object
days
required
integer format: int64
libraries
required
Array<string> | null
name
required
string
nonexpiring
required
boolean
scopes
required
Array<string> | null
Examplegenerated
{ "days": 1, "libraries": [ "example" ], "name": "example", "nonexpiring": true, "scopes": [ "example" ]}Responses
Section titled “Responses”Operation completed.
Media typeapplication/json
object
created_at
required
integer format: int64
expires_at
required
integer format: int64
id
required
string
last_used_at
required
integer format: int64
libraries
required
Array<string> | null
name
required
string
revoked_at
required
integer format: int64
scopes
required
Array<string> | null
secret
required
string
key
additional properties
any
Examplegenerated
{ "created_at": 1, "expires_at": 1, "id": "example", "last_used_at": 1, "libraries": [ "example" ], "name": "example", "revoked_at": 1, "scopes": [ "example" ], "secret": "example"}No valid session or API token (authentication-required), or the credential sent is invalid (invalid-credentials).
Media typeapplication/problem+json
object
code
required
string
detail
required
string
status
required
integer format: int64
title
required
string
type
required
string
key
additional properties
any
Examplegenerated
{ "code": "example", "detail": "example", "status": 1, "title": "example", "type": "example"}default
Section titled “default”Stable account problem code; authentication, authority, validation or lifecycle conflict.
Media typeapplication/problem+json
object
code
required
string
detail
required
string
status
required
integer format: int64
title
required
string
type
required
string
key
additional properties
any
Examplegenerated
{ "code": "example", "detail": "example", "status": 1, "title": "example", "type": "example"}