---
title: "Authenticate"
method: POST
path: "/auth/token"
tags: ["Auth"]
---

# Authenticate

`POST /auth/token`

## Request

- Base URL: `https://am1.portal.api.nasuni.com`
- URL: `https://am1.portal.api.nasuni.com/auth/token`
- Auth: one of:
  - API key in header `x-service-key` and API key in header `x-service-secret`
  - API key in header `x-user-key`
  - OAuth 2
    - Client credentials
    - Token URL: `/auth/token`
- TypeScript: <https://skmtc.dev/nasuni/apis/portal-api/docs/auth/token/post.ts> (a function with typed inputs; its response is checked against the schema)

Authenticate using one of the following methods:
- **Service Keys (headers)**: Provide both `x-service-key` and `x-service-secret` headers
- **User Keys (header)**: Provide `x-user-key` header
- **OAuth2 Client Credentials (form body)**: POST `application/x-www-form-urlencoded` with `grant_type=client_credentials`, `client_id=<service_key>`, `client_secret=<service_secret>` (RFC 6749 §4.4). Compatible with standard OAuth2 client libraries such as Grafana Infinity, Datadog, Splunk, and ServiceNow.

Returns access and refresh tokens for subsequent API calls.

## Request body `application/x-www-form-urlencoded`

- object
  - `grant_type` 'client_credentials', required: Must be `client_credentials`.
  - `client_id` string, required: Portal service key (equivalent to the `x-service-key` header).
  - `client_secret` string, uuid, required: Portal service secret (equivalent to the `x-service-secret` header).

## Response `200`

Authentication successful

- TokensDto
  - `access_token` string, required
  - `refresh_token` string, required
  - `token_type` string
  - `expires_in` integer, nullable

## Other responses

- `400`: Bad request
- `401`: Not authenticated
- `403`: Insufficient permissions
- `408`: Request timeout
- `422`: Invalid input data
- `500`: Internal server error

---

[API](https://skmtc.dev/nasuni/apis/portal-api.md) - [All operations](https://skmtc.dev/nasuni/apis/portal-api/llms.txt) - [OpenAPI document](https://skmtc.dev/nasuni/apis/portal-api/revisions/2a505bec6d14?raw)
