# Create a new login token.

`POST /admin/login_tokens`

Authentication (security requirement alternatives):

```json
[
  {
    "ApiKey": []
  }
]
```

- ApiKey: apiKey, header X-API-Key

Request body: application/json

Type: object

Schema: [Api_Admin_NewLoginToken](https://sourcey-azuracast.pages.dev/docs/api/models/api-admin-newlogintoken/index.md)

- `user` (required)
  Type: unknown
  
  User ID or e-mail address.
  
  anyOf:
    Type: integer, int64
  
    Type: string

- `type` (optional)
  Type: unknown; nullable
  
  oneOf:
    Reference: [LoginTokenTypes](https://sourcey-azuracast.pages.dev/docs/api/models/logintokentypes/index.md); Type: string
    
    enum: ["reset_password","login"]

- `comment` (optional)
  Type: string; nullable
  
  Example:
  
  ```json
  "SSO Login"
  ```

- `expires_minutes` (optional)
  Type: integer

Responses:

- 200: Success

Content type: application/json

Type: object

Schema: [Api_Admin_NewLoginTokenResponse](https://sourcey-azuracast.pages.dev/docs/api/models/api-admin-newlogintokenresponse/index.md)

- `success` (required)
  Type: boolean
  
  Example:
  
  ```json
  true
  ```

- `message` (required)
  Type: string
  
  Example:
  
  ```json
  "Changes saved successfully."
  ```

- `formatted_message` (required)
  Type: string
  
  Example:
  
  ```json
  "<b>Changes saved successfully.</b>"
  ```

- `record` (required)
  Reference: [UserLoginToken](https://sourcey-azuracast.pages.dev/docs/api/models/userlogintoken/index.md); Type: object

- `links` (required)
  Type: object
  
  readOnly: true
  
  Additional properties: 
    Type: string

- 403: Access denied.

Content type: application/json

Type: object

Schema: [Api_Error](https://sourcey-azuracast.pages.dev/docs/api/models/api-error/index.md)

- `code` (required)
  Type: integer
  
  The numeric code of the error.
  
  Example:
  
  ```json
  500
  ```

- `type` (required)
  Type: string
  
  The programmatic class of error.
  
  Example:
  
  ```json
  "NotLoggedInException"
  ```

- `message` (required)
  Type: string
  
  The text description of the error.
  
  Example:
  
  ```json
  "Error description."
  ```

- `formatted_message` (required)
  Type: string; nullable
  
  The HTML-formatted text description of the error.
  
  Example:
  
  ```json
  "<b>Error description.</b><br>Detailed error text."
  ```

- `extra_data` (required)
  Type: array
  
  Stack traces and other supplemental data.
  
  Items:
    Type: any

- `success` (required)
  Type: boolean
  
  Used for API calls that expect an \Entity\Api\Status type response.
  
  Example:
  
  ```json
  false
  ```

- 500: A generic exception has occurred.

Content type: application/json

Type: object

Schema: [Api_Error](https://sourcey-azuracast.pages.dev/docs/api/models/api-error/index.md)

- `code` (required)
  Type: integer
  
  The numeric code of the error.
  
  Example:
  
  ```json
  500
  ```

- `type` (required)
  Type: string
  
  The programmatic class of error.
  
  Example:
  
  ```json
  "NotLoggedInException"
  ```

- `message` (required)
  Type: string
  
  The text description of the error.
  
  Example:
  
  ```json
  "Error description."
  ```

- `formatted_message` (required)
  Type: string; nullable
  
  The HTML-formatted text description of the error.
  
  Example:
  
  ```json
  "<b>Error description.</b><br>Detailed error text."
  ```

- `extra_data` (required)
  Type: array
  
  Stack traces and other supplemental data.
  
  Items:
    Type: any

- `success` (required)
  Type: boolean
  
  Used for API calls that expect an \Entity\Api\Status type response.
  
  Example:
  
  ```json
  false
  ```

## Examples

### cURL

```bash
curl -X POST 'https://demo.azuracast.com/api/admin/login_tokens' \
  -H 'X-API-Key: YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "user": 0,
  "type": "reset_password",
  "comment": "SSO Login",
  "expires_minutes": 0
}'
```

### JavaScript

```javascript
const body = `{
  "user": 0,
  "type": "reset_password",
  "comment": "SSO Login",
  "expires_minutes": 0
}`;

const response = await fetch('https://demo.azuracast.com/api/admin/login_tokens', {
  method: 'POST',
  headers: {
    'X-API-Key': 'YOUR_TOKEN',
    'Content-Type': 'application/json',
  },
  body,
});

const data = await response.text();
```

### Python

```python
import requests

body = '''{
  "user": 0,
  "type": "reset_password",
  "comment": "SSO Login",
  "expires_minutes": 0
}'''

response = requests.post(
    'https://demo.azuracast.com/api/admin/login_tokens',
    data=body.encode('utf-8'),
    headers={
        'X-API-Key': 'YOUR_TOKEN',
        'Content-Type': 'application/json',
    },
)
print(response.text)
```
