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

# Generate Token

Use this API to generate a JWT token used by your client to authenticate with Velt. The token encodes user information and optional properties such as organization and admin status.

<Info>
  * JWT token expires in 48 hours.
  * For v1, `apiKey` and `authToken` are provided in the request body (not headers).
</Info>

# Endpoint

`POST https://api.velt.dev/v1/auth/token/get`

# Headers

<ParamField header="Content-Type" type="string" required>
  application/json
</ParamField>

# Body

#### Params

<ParamField body="data" type="object" required>
  <Expandable title="properties">
    <ParamField body="apiKey" type="string" required>
      Your Velt API Key.
    </ParamField>

    <ParamField body="authToken" type="string" required>
      Your Auth Token from the Velt console. See <a href="/security/auth-tokens">Auth Tokens</a>.
    </ParamField>

    <ParamField body="userId" type="string" required>
      Unique identifier for the user.
    </ParamField>

    <ParamField body="userProperties" type="object">
      <Expandable title="properties">
        <ParamField body="organizationId" type="string" required>
          Organization ID. Should match the `organizationId` used in the `identify` call.
        </ParamField>

        <ParamField body="isAdmin" type="boolean">
          Whether the user has admin privileges. This is the only supported way to set a user as admin. Do not set this in the `identify` call.
        </ParamField>

        <ParamField body="email" type="string">
          User email. If provided, it is validated against the email used in the `identify` call.
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

## **Example Requests**

#### Generate token with organization and admin

```JSON theme={null}
{
  "data": {
    "apiKey": "YOUR_API_KEY",
    "authToken": "YOUR_AUTH_TOKEN",
    "userId": "yourUserId",
    "userProperties": {
      "isAdmin": true,
      "organizationId": "YOUR_ORGANIZATION_ID",
      "email": "user@example.com"
    }
  }
}
```

#### Minimal token request

```JSON theme={null}
{
  "data": {
    "apiKey": "YOUR_API_KEY",
    "authToken": "YOUR_AUTH_TOKEN",
    "userId": "yourUserId",
    "userProperties": {
      "organizationId": "YOUR_ORGANIZATION_ID"
    }
  }
}
```

# Response

<Warning>
  Generate the JWT token on your server, not your client, to keep your secrets secure.
</Warning>

#### Success Response

```JSON theme={null}
{
  "result": {
    "status": "success",
    "message": "Token generated successfully.",
    "data": {
      "token": "YOUR_JWT_TOKEN"
    }
  }
}
```

#### Failure Response

```JSON theme={null}
{
  "error": {
    "message": "Auth token not found.",
    "status": "INVALID_ARGUMENT"
  }
}
```

<ResponseExample>
  ```js theme={null}
  {
    "result": {
      "status": "success",
      "message": "Token generated successfully.",
      "data": {
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
      }
    }
  }
  ```
</ResponseExample>
