---
title: Authentication
summary: How tokens are created, what they can do, how long they last, and how to refresh or rotate them.
group: Get started
order: 20
---

Every request carries one header:

```
Authorization: Bearer <token>
```

The word `Bearer`, one space, then the token. The prefix is case-sensitive.

## One token, one company

A token belongs to one Sequifi company. It decides whose data you read and write; there is no company id in any URL or body. To work with two companies, use two tokens.

The base URL is the same for every company: `https://marketplace-api.sequifi.com`.

## Creating a token

An admin in your Sequifi company creates tokens in the web app under **Admin > Tools > API Credentials**:

1. Choose **Create Credentials** and enter a **Credential Name** that says what uses it, for example `CRM sync (production)`. Names must be unique.
2. Choose **Generate Credentials**.
3. Copy both tokens from the banner: the **access token** for calls and the **refresh token** for renewing it. They are shown once; choose **I've saved these tokens** only after you have stored them.
4. Store them in a secrets manager or environment variables such as `SEQUIFI_TOKEN` and `SEQUIFI_REFRESH_TOKEN`. Never put them in source code, a prompt or a chat.

The same page lists your credentials, shows when each expires, and lets you **Pause**, **Resume** or **Delete Permanently** each one.

## What a token can do

A token can call every endpoint in this reference, for reads and writes, including personal data, terminations and position changes. There are no per-token scopes today. Treat a token like an admin password: one per integration, stored as a secret, deleted when the integration is retired.

## Lifetime

Access tokens last **60 days** from when they are created. The refresh token that comes with them lasts **66 days**.

## Refreshing a token

An integration can renew its own access, no admin needed. Before the access token expires, send the refresh token:

```
POST https://marketplace-api.sequifi.com/v1/auth/refreshToken
Content-Type: application/json

{ "refresh_token": "<your refresh token>" }
```

This call takes no `Authorization` header. You get back a new access token (60 days) and a new refresh token (66 days):

- Store the new refresh token before using the new access token. Each refresh token works once.
- The old access token stops working within about five minutes.
- Refreshing on a schedule, for example weekly, keeps an integration running indefinitely.
- If a refresh response is lost, retry with the same refresh token within 60 seconds and you get the same pair. After that, reusing an old refresh token pauses the credential as a precaution, and an admin has to resume or replace it. Refresh from one place and keep one copy.
- An admin can still Pause or Delete the credential at any time; that stops refreshing too.

See [Refresh an access token](https://apidocs.sequifi.com/reference/refresh-access-token.md) for the full reference.

## Rotating by hand

To replace a token without the refresh call, or after a refresh token has expired:

1. Create a new token with a new name.
2. Switch your integration to it.
3. Pause or delete the old credentials.

Changes can take up to about five minutes to apply: a token you just paused or deleted may keep working briefly, and a new token is usable right away.

## When authentication fails

A missing, malformed, unknown, expired, paused or deleted token gets `401` with this body:

```json
{ "message": "Unauthorized" }
```

That body has no `status`/`data` envelope, because it comes from the gateway in front of the API. Don't retry a `401` in a loop: fix or rotate the token.

## Managing tokens from code

Refreshing is the only token operation available from code. There is no API for creating, pausing or deleting tokens; manage them in the web app, under Admin > Tools > API Credentials, so a person decides who has access.
