CreateApiToken

Create an API token

POST
/openapi/auth/CreateApiToken

A long-lived token rooted at a folder, for a platform that provisions one per customer or a job that runs unattended. The secret is answered once and cannot be recovered; store it. Callable with an account session only: another API token, a delegated token or a workspace token is refused with CREDENTIAL_CREATION_NOT_ALLOWED.

Try it#

Edit the request and send it; it runs against this instance with your token, and the examples follow the form.

Authorization
Bearer <auth token>
Content-Type
application/json
Body
1 2 3 4 5 6 7 8 9
Authorization: Bearer <auth token>
Content-Type: application/json
Accept: application/json
curl -X POST "$BIMWORKS_URL/openapi/auth/CreateApiToken" \
  -H "Authorization: Bearer $BIMWORKS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Customer 42 uploads",
  "node_uuid": "0f1e2d3c-4b5a-4968-8776-655443322110",
  "scopes": [
    "fs:read",
    "model:upload"
  ],
  "expires_on": "2027-06-30"
}'
Send to see the response

Examples#

curlshell
curl -X POST "$BIMWORKS_URL/openapi/auth/CreateApiToken" \
  -H "Authorization: Bearer $BIMWORKS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Customer 42 uploads",
  "node_uuid": "0f1e2d3c-4b5a-4968-8776-655443322110",
  "scopes": [
    "fs:read",
    "model:upload"
  ],
  "expires_on": "2027-06-30"
}'

The examples are complete programs in the OpenAPI SDKs, all in the same four steps. The method in each SDK's reference: Java · .NET · TypeScript · PHP · Python.

Request body#

CreateApiTokenRequest · application/json

FieldTypeDescription
node_uuiduuidrequiredThe Node (folder) the token is rooted at; needs write rights on it
namestringrequiredThe name of the token
scopesarray of stringrequiredThe scopes the token grants, as wire names (fs:read, model:upload, ...). A scoped caller can grant no more than it has itself
expires_onstringoptionalWhen the token expires: a date (YYYY-MM-DD, the end of that day in UTC) or a date-time. At most auth.api_token_max_expiry ahead (3 years by default); 1 month when absent
cors_enabled_domainsarray of stringoptionalThe browser origins that may use the token, with only_cors_enabled_addresses
only_cors_enabled_addressesbooleanoptionalRefuse calls from other origins than cors_enabled_domains
white_listed_ip_addressesarray of stringoptionalThe client addresses that may use the token, with only_white_listed_ip_addresses
only_white_listed_ip_addressesbooleanoptionalRefuse calls from other addresses than white_listed_ip_addresses
bim_contextstringoptionalThe regional context of the token One of DEFAULT, MKM, HONG_KONG, NL, GB. Default DEFAULT.

Responses#

StatusSchemaDescription
200ApiTokenSecretThe new token, with its secret
400ErrorResponseInvalid input: a missing or invalid argument, an invalid query/identifier/path, a state conflict caused by the request (for example a Node name that already exists), or an uploaded file that was rejected because it cannot be read (type for example INVALID_INPUT_FILE, NO_CONVERTIBLE_CONTENT or one of the StepParserErrorCode codes; uploading the same file again fails the same way)
401ErrorResponseAuthentication failed: the bearer token is missing, malformed, expired or otherwise invalid, or the provided login credentials are incorrect
403ErrorResponseAuthenticated, but not allowed: no read/write rights on the target Node, the token's task or IP scope does not allow this call, or a required user feature is missing
404ErrorResponseThe referenced entity (Node, Version, model file, upload, ...) does not exist
429ErrorResponseToo many requests from this client in a short time, on an installation that limits the request rate. Wait the number of seconds in Retry-After before trying again
500ErrorResponseAn unexpected server-side error (database, routing, IO, unknown)
503ErrorResponseBIM.works is temporarily unavailable: it is restarting, stopped, or down for scheduled maintenance (type SERVICE_UNAVAILABLE or MAINTENANCE). Wait the number of seconds in Retry-After before trying again
504ErrorResponseBIM.works did not respond in time (type REQUEST_TIMED_OUT). The request may still be completed: check its result before trying again
Generated from api.yml·openapi.json