Create an API token

Needs permission api-token:write.

Issues a new client credential for your account. The response carries clientSecret exactly once — store it before doing anything else. Retrying with the same Idempotency-Key answers 200 with the token already made and no secret; if the secret has been lost, rotate the token.

roleId is the token's role (GET /roles, those listing api-token in assignableTo); leave it out for your account's default role. A token's role never covers API tokens, roles or the account, whatever it says. Giving a token a role needs a caller who manages API tokens where it applies (403 access_management_denied otherwise; a person or an API token alike), and the role's permissions must be ones you hold (403 role_assignment_denied). A role for people only answers 400 role_not_assignable, and while only Administrator can be given out any other role answers 400 role_not_yet_available. A role you leave out on access it did not have is your account's default role (GET /customer/access-settings), and administrator while only Administrator can be given out; when that default role is for people only, the token is refused with 400 role_not_assignable and you name its role. Every response lists the token's role at each place in roles.

allowedIpRanges lists the address ranges the token may be used from: 1 to 20, IPv4 or IPv6, such as 203.0.113.0/24 or 2001:db8::/32, with no spaces or leading zeros. Each is stored as its network address. From anywhere else every API, this one included, answers 403 ip_not_allowed. 400 invalid_ip_range names a range we cannot use. Only a person changes or lifts an existing token's ranges: an API token is refused with 403 insufficient_permissions, missingPermission: api-token:write. An API token restricted to ranges issues or rotates only tokens within them (403 token_ranges_wider_than_yours); one it issues without ranges gets its own. Leave it out to allow any address.

State what the token reaches as either organisationIds or allOrganisations: true, never both. allOrganisations grants account-wide access — every organisation the account owns, including ones added later — and only somebody who already holds account-wide access may grant it (403 whole_customer_access_denied otherwise). name is 3 to 100 characters and unique within your account.

An account may hold 5 API tokens, counting every client credential it holds and not only the ones created here. Being over the limit revokes nothing; it only refuses a new one. Three things answer 409, told apart by message.token:

  • token_limit_reached — the account already holds 5 tokens. Revoke one that is no longer used, or contact support to raise the allowance.
  • duplicate_token_name — another token in your account has that name.
  • idempotency_key_reused — that Idempotency-Key was already used for a different request body.

403 billing_not_set_up when billing is not set up for the account yet — email [email protected] to agree pricing and set it up. Accounts onboarded by Flow Payroll are already set up.

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…
Body Params

Issues a new API token (client credential) for your account.

string | null

Required. A display name, unique within your account.

organisationIds
array of strings | null
deprecated

Deprecated: use access. Deprecated: use access with Organisation entries. The organisations the token reaches. State exactly
one of this and allOrganisations.

organisationIds
boolean | null
deprecated

Deprecated: use access. Deprecated: use access with an Account entry. Give the credential access to every organisation the
account owns, including ones added later,
instead of the ones named in organisationIds. State exactly one of the two. This is the
widest grant this API makes, so only somebody who already holds account-wide access may ask for it.

access
array of objects | null

The access to give: one grant per scope, each with its own role. Replaces organisationIds,
allOrganisations and roleId, which are deprecated: send one or the other, never both (400
access_with_deprecated_fields).

access
allowedIpRanges
array of strings | null

Optional. Address ranges the token may be used from, such as ["203.0.113.0/24"]: up to 20, IPv4 or IPv6.
Leave it out to allow any address. A request from anywhere else is refused, here and on every other API.

allowedIpRanges
Headers
string
length ≤ 255

Your own key for this create, so a retry after a lost response finds what the first attempt made instead of making a second one. Any unique string up to 255 characters; a UUID is the usual choice. Send the same value on every retry of the same request, and a new value for a new one — reusing a key for a different body answers 409 idempotency_key_reused. Keys are remembered for 24 hours. Optional, and a request without one simply has no replay protection.

Responses

Language
Credentials
Header
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json