> ## Documentation Index
> Fetch the complete documentation index at: https://help.ship.uniuni.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication

> Authenticate with the UniUni Partner API using JWT access tokens

The Partner API uses JWT-based authentication. This is separate from the Client API — you need a Partner API key to access these endpoints.

**Base URL:** `https://api.ship.uniuni.com/partner`

## Step 1: Get an access token

Exchange your API key for a JWT access token by calling the authentication endpoint.

<Note>
  Access tokens are valid for **24 hours**. Store the token and reuse it until it expires.
</Note>

### Request

```
GET /auth/token
```

| Header      | Value                |
| ----------- | -------------------- |
| `X-API-Key` | Your Partner API key |

### Response

```json theme={null}
{
  "success": true,
  "message": "Get token successfully",
  "data": {
    "accessToken": "eyJhbGciOiJIUzI1NiIs..."
  }
}
```

### Error responses

<Tabs>
  <Tab title="Missing API Key">
    ```json theme={null}
    {
      "success": false,
      "message": "Missing API Key"
    }
    ```
  </Tab>

  <Tab title="Error Generating Token">
    ```json theme={null}
    {
      "success": false,
      "message": "Error generating API token"
    }
    ```
  </Tab>
</Tabs>

### Example

```bash theme={null}
curl -X GET https://api.ship.uniuni.com/partner/auth/token \
  -H "X-API-Key: your_api_key_here"
```

## Step 2: Use the access token

Include the JWT token in the `Authorization` header for all subsequent API calls.

```
Authorization: Bearer <accessToken>
```

### Example

```bash theme={null}
curl -X GET "https://api.ship.uniuni.com/partner/track?trackingId=UR12345678901234567" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..."
```

## Auth error codes

| Error Code          | Description                                          |
| ------------------- | ---------------------------------------------------- |
| `MissingTokenError` | No `Authorization` header provided                   |
| `ExpiredTokenError` | The JWT access token has expired — request a new one |
| `InvalidTokenError` | The token is malformed or the API key is invalid     |
| `TokenPayloadError` | The token payload could not be decoded               |

### Error response example

```json theme={null}
{
  "success": false,
  "message": "Missing API Key"
}
```
