> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qwoty.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Créer un token API

> Créer un nouveau token API pour l'authentification

## Autorisation

<ParamField header="Authorization" type="string" required>
  Token Bearer pour l'authentification. Format : `Bearer qwoty_your_token`
</ParamField>

## Corps de la requête

<ParamField body="name" type="string" required>
  Un nom descriptif pour le token API
</ParamField>

<ParamField body="expires_at" type="string">
  Date d'expiration optionnelle au format ISO 8601 (ex. : "2024-12-31T23:59:59Z")
</ParamField>

<ParamField body="permissions" type="object">
  Configuration optionnelle des permissions pour le token
</ParamField>

## Réponse

<ResponseField name="success" type="boolean">
  Indique si l'opération s'est déroulée avec succès
</ResponseField>

<ResponseField name="data" type="object">
  L'objet token API créé

  <Expandable title="Objet Token">
    <ResponseField name="id" type="string">
      Identifiant unique du token
    </ResponseField>

    <ResponseField name="name" type="string">
      Nom du token
    </ResponseField>

    <ResponseField name="token" type="string">
      La valeur réelle du token (retournée uniquement lors de la création)
    </ResponseField>

    <ResponseField name="expires_at" type="string">
      Date d'expiration du token
    </ResponseField>

    <ResponseField name="created_at" type="string">
      Horodatage de création
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://qwoty.app/api/tokens \
    --header 'Content-Type: application/json' \
    --data '{
      "name": "Production API Token",
      "expires_at": "2025-12-31T23:59:59Z"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://qwoty.app/api/tokens', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      name: 'Production API Token',
      expires_at: '2025-12-31T23:59:59Z',
    }),
  })

  const data = await response.json()
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://qwoty.app/api/tokens',
      json={
          'name': 'Production API Token',
          'expires_at': '2025-12-31T23:59:59Z'
      }
  )

  data = response.json()
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "success": true,
    "data": {
      "id": "tok_123abc",
      "name": "Production API Token",
      "token": "qwoty_live_abc123def456...",
      "expires_at": "2025-12-31T23:59:59Z",
      "created_at": "2024-01-15T10:30:00Z"
    }
  }
  ```

  ```json 400 theme={null}
  {
    "error": "Invalid request data",
    "details": {
      "name": ["Required field"]
    }
  }
  ```
</ResponseExample>
