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

# Get a token

> Issues a JWT pair for the email and password of an AiGenda account.

## Request body

<ParamField body="username" type="string" required>
  Account email. The field is called `username`, but it holds the email.
</ParamField>

<ParamField body="password" type="string" required>
  Account password.
</ParamField>

## Response

<ResponseField name="access" type="string">
  Token for the `Authorization: Bearer` header. Lives for 30 days.
</ResponseField>

<ResponseField name="refresh" type="string">
  Token for refreshing `access`. Lives for 1 day.
</ResponseField>

More on lifetimes and refreshing: [Authentication](/en/authentication).

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.aigenda.tech/api/token/" \
    -H "Content-Type: application/json" \
    -d '{
      "username": "you@example.com",
      "password": "your-password"
    }'
  ```

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

  response = requests.post(
      "https://api.aigenda.tech/api/token/",
      json={
          "username": "you@example.com",
          "password": "your-password",
      },
      timeout=30,
  )
  response.raise_for_status()
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://api.aigenda.tech/api/token/", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      "username": "you@example.com",
      "password": "your-password"
    }),
  });
  const data = await response.json();
  console.log(data);
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "refresh": "eyJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCJ9.sig",
    "access": "eyJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIn0.sig"
  }
  ```

  ```json 401 theme={null}
  {
    "detail": "No active account found with the given credentials"
  }
  ```
</ResponseExample>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.