createApiKey
ApiKeyResponseWrapper createApiKey(CreateApiKeyRequestDto)
POST /api/2.0/keys
Create a user API key
Creates an API key that authenticates requests as the calling account, and is the only operation that ever returns the secret. Any portal member except a guest may create one; when the portal limits developer tools to administrators, only a DocSpace administrator may call it. The call is not idempotent - every call issues a new key - and it is throttled, so a client that retries on a timeout can end up with several keys. The answer carries the full secret in key: it is shown here and never again, later reads expose only the last four characters in keyPostfix, so store it now. Pass the scopes the key may use in permissions, taking the values from GET api/2.0/keys/permissions; pass * or omit the field to record a key without scope restrictions, and set expiresInDays to make it expire, otherwise it stays valid until it is deleted. An empty permissions array and an unknown scope are both rejected with 400. Send the key in the Authorization header as Bearer sk-... to use it.
Parameters
| Name | In | Type | Description | Notes |
|---|---|---|---|---|
| CreateApiKeyRequestDto | body | CreateApiKeyRequestDto | [optional] |
Responses
| Status code | Description | Type | Response headers |
|---|---|---|---|
| 200 | The new API key, with the full secret in the key field | ApiKeyResponseWrapper | X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset |
| 400 | The request body cannot be read or has no name, the name is empty or longer than 30 characters, expiresInDays is outside 1-365, or the permissions array is empty or contains a scope the portal does not know | - | - |
| 403 | The caller is a guest, or the portal limits developer tools to administrators | - | - |
| 401 | Unauthorized | ErrorApiResponse | - |
| 429 | Too Many Requests. | ErrorApiResponse | Retry-After |
| 500 | Internal Server Error. | ErrorApiResponse | - |
| 502 | Bad Gateway. Returned by the reverse proxy, response body may be HTML and not JSON. | - | - |
| 503 | Service Unavailable. Returned by the reverse proxy, response body may be HTML and not JSON. | - | - |
Return type
Authorization
Basic, OAuth2 (scopes: read, write), ApiKeyBearer, asc_auth_key, Bearer, OpenId
HTTP request headers
- Content-Type: application/json
- Accept: application/json