Create a new API key belonging to the logged-in user

users_post_api_keys(id, expires_in, name, constraints = NULL)

Arguments

id

string required. The ID of the user or 'me'.

expires_in

integer required. The number of seconds the key should last for.

name

string required. The name of the API key.

constraints

array optional. An array containing the following fields:

  • constraint string, The path matcher of the constraint.

  • constraintType string, The type of constraint (exact/prefix/regex/verb).

  • getAllowed boolean, Whether the constraint allows GET requests.

  • headAllowed boolean, Whether the constraint allows HEAD requests.

  • postAllowed boolean, Whether the constraint allows POST requests.

  • putAllowed boolean, Whether the constraint allows PUT requests.

  • patchAllowed boolean, Whether the constraint allows PATCH requests.

  • deleteAllowed boolean, Whether the constraint allows DELETE requests.

Value

A list containing the following elements:

id

integer, The ID of the API key.

name

string, The name of the API key.

expiresAt

string, The date and time when the key expired.

createdAt

string, The date and time when the key was created.

revokedAt

string, The date and time when the key was revoked.

lastUsedAt

string, The date and time when the key was last used.

scopes

array, The scopes which the key is permissioned on.

useCount

integer, The number of times the key has been used.

expired

boolean, True if the key has expired.

active

boolean, True if the key has neither expired nor been revoked.

constraints

array, An array containing the following fields:

  • constraint string, The path matcher of the constraint.

  • constraintType string, The type of constraint (exact/prefix/regex/verb).

  • getAllowed boolean, Whether the constraint allows GET requests.

  • headAllowed boolean, Whether the constraint allows HEAD requests.

  • postAllowed boolean, Whether the constraint allows POST requests.

  • putAllowed boolean, Whether the constraint allows PUT requests.

  • patchAllowed boolean, Whether the constraint allows PATCH requests.

  • deleteAllowed boolean, Whether the constraint allows DELETE requests.

token

string, The API key.