> For the complete documentation index, see [llms.txt](https://docs.ionos.com/cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ionos.com/cloud/api-reference/security/authentication/tokens/create-new-tokens.md).

# Create New Tokens

Users can generate new tokens ([JWT](https://jwt.io/) or [JSON Web Token](https://tools.ietf.org/html/rfc7519)). By default, new tokens are linked to the user’s contract. Users with multiple contracts must provide the contract number, for which the token is generated, in the `X-Contract-Number` header; otherwise, an error response is returned.\
\
To access this endpoint, 'Basic Authentication' or 'Token Authentication' tokens with valid credentials must be encapsulated in the header, by users with one or with multiple contracts.

**Note:**\
\
Basic Authentication is supported only when 2-Factor Authentication is not configured.The response will contain a newly-generated token for accessing any IONOS CLOUD APIs (Auth API, Cloud API, Reseller API, Activity Log API, and others). The token can be used to access the APIs without providing the contract number in the \`X-Contract-Number\` header, by users with one or with multiple contracts. However, a valid contract number must be provided in the \`X-Contract-Number\` header to access the Auth API. By default, generated access tokens will expire after one year (subject to change).\
\
**Attention:**\
\
We are currently enforcing a limit of **100 active tokens** per user. If you attempt to create a new token when you have already reached this limit, the API will return an error response. This limit is subject to change in the future.\ <br>

```json
{"openapi":"3.0.1","info":{"title":"Auth API","version":"1.0"},"tags":[{"name":"tokens","description":"Everything about tokens"}],"servers":[{"url":"https://api.ionos.com/auth/v1"}],"security":[{"BasicAuthentication":[]},{"TokenAuthentication":[]}],"components":{"securitySchemes":{"BasicAuthentication":{"type":"http","description":"You will need to base64 encode the string containing your credentials. <div style=\"padding: 15px; border: 1px solid #d1ecf1; background-color: #d1ecf1; color: #0c5460; margin-bottom: 15px;\">\n  <strong>Note:</strong><br/><br/>\n  <ul><li><b>Basic Authentication</b> is supported only when <b>2-Factor \n  Authentication</b> is not configured.</li>\n  <li>Users with <b>2-Factor \n  Authentication</b> activated must generate new 2FA-secured tokens in the DCD using [Token Manager](https://docs.ionos.com/cloud/set-up-ionos-cloud/management/identity-access-management/token-manager). \n  These tokens do not inherit the <b>2FA-secured</b> property by default.</li><li>Token deletion is only possible using the <b>Token Manager</b>.</li>\n</div> Separate your username and password with a colon. Example: ``username:password`` and send it as 'Authorization' request header. For more information, see [Basic access authentication](https://en.wikipedia.org/wiki/Basic_access_authentication) \n","scheme":"basic"},"TokenAuthentication":{"type":"apiKey","description":"Please provide header value as 'Bearer <token>' and add 'Bearer' HTTP Authorization Scheme before the token.","name":"Authorization","in":"header"}},"schemas":{"Jwt":{"type":"object","properties":{"token":{"type":"string","description":"JSON Web Token (JWT) Base64url strings separated by dots"}}},"Error":{"type":"object","properties":{"httpStatus":{"type":"integer","description":"HTTP Response Code","format":"int32"},"messages":{"type":"array","items":{"type":"object","properties":{"errorCode":{"type":"string","description":"Numeric error code of error message."},"message":{"type":"string","description":"Error message."}}}}}}}},"paths":{"/tokens/generate":{"get":{"tags":["tokens"],"summary":"Create New Tokens","description":"Users can generate new tokens ([JWT](https://jwt.io/) or [JSON Web Token](https://tools.ietf.org/html/rfc7519)). By default, new tokens are linked to the user’s contract. Users with multiple contracts must provide the contract number, for which the token is generated, in the `X-Contract-Number` header; otherwise, an error response is returned.<br><br> To access this endpoint, 'Basic Authentication' or 'Token Authentication' tokens with valid credentials must be encapsulated in the header, by users with one or with multiple contracts.  <div style=\"padding: 15px; border: 1px solid #d1ecf1; background-color: #d1ecf1; color: #0c5460; margin-bottom: 15px;\">\n  <strong>Note:</strong><br/><br/>\n  <b>Basic Authentication</b> is supported only when <b>2-Factor \n  Authentication</b> is not configured.\n</div> The response will contain a newly-generated token for accessing any IONOS CLOUD APIs (Auth API, Cloud API, Reseller API, Activity Log API, and others). The token can be used to access the APIs without providing the contract number in the `X-Contract-Number` header, by users with one or with multiple contracts. However, a valid contract number must be provided in the `X-Contract-Number` header to access the Auth API. By default, generated access tokens will expire after one year (subject to change). <br/><br/> <div style=\"margin-top: 10px;padding: 15px;border: 1px solid #ffa8a3;background-color: #ffa8a3;color: #c80a00;margin-bottom: 15px;\">\n  <strong>Attention:</strong><br/><br/>\n  We are currently enforcing a limit of <strong>100 active tokens</strong> per user. If you attempt to create a new token\n  when you have already reached this limit, the API will return an error response. This limit is subject to change in the future.\n</div> <br/><br/>\n","operationId":"tokensGenerate","parameters":[{"name":"X-Contract-Number","in":"header","description":"Users with multiple contracts must provide the contract number, for which the token is generated.","schema":{"type":"integer","format":"int32"}},{"name":"ttl","in":"query","description":"The maximum time that the access token will be valid for use within the application in seconds.","schema":{"maximum":31536000,"minimum":60,"type":"integer","format":"int32","default":31536000}}],"responses":{"200":{"description":"The JSON Web Token, associated with user credentials.","headers":{"X-RateLimit-Remaining":{"description":"The number of requests that can still be made without triggering a failure response.","schema":{"type":"integer","format":"int32"}},"X-RateLimit-Limit":{"description":"The average number of requests per minute allowed.","schema":{"type":"integer","format":"int32"}},"X-RateLimit-Burst":{"description":"The maximum number of concurrent API requests allowed.","schema":{"type":"integer","format":"int32"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Jwt"}}}},"400":{"description":"Invalid data has been sent or token limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"An invalid username/password or token provided, or the User or the Contract is not valid for endpoint access.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The User or the Contract is not valid for endpoint access.","headers":{"X-RateLimit-Remaining":{"description":"The number of requests that can still be made without triggering a failure response.","schema":{"type":"integer","format":"int32"}},"X-RateLimit-Limit":{"description":"The average number of requests per minute allowed.","schema":{"type":"integer","format":"int32"}},"X-RateLimit-Burst":{"description":"The maximum number of concurrent API requests allowed.","schema":{"type":"integer","format":"int32"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"The User or the Contract is not valid for endpoint access.","headers":{"X-RateLimit-Remaining":{"description":"The number of requests that can still be made without triggering a failure response.","schema":{"type":"integer","format":"int32"}},"X-RateLimit-Limit":{"description":"The average number of requests per minute allowed.","schema":{"type":"integer","format":"int32"}},"X-RateLimit-Burst":{"description":"The maximum number of concurrent API requests allowed.","schema":{"type":"integer","format":"int32"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.ionos.com/cloud/api-reference/security/authentication/tokens/create-new-tokens.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
