# Authentication

Send a token and your account id with each request, and choose what each token may change.

HTML version: https://t.momentic.studio/docs/api/authentication

## Headers

Each request sends three headers:

- Authorization: Bearer followed by an API token. Create one in **Settings**, **API tokens**. The token is shown once.
- Harvest-Account-Id: the account id shown on the same page. The workspace slug works too.
- User-Agent: the name of your application and a contact, such as MyApp (admin@example.com). A request without it is refused with 400.

```bash
curl "https://t.momentic.studio/api/v2/users/me" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Harvest-Account-Id: $ACCOUNT_ID" \
  -H "User-Agent: MyApp (admin@example.com)"
```

## A token acts as its person

A token reads and changes what the person who created it can read and change in the app, with that person's role at the time of the request. A member reads their own time entries. A manager also reads the entries on projects they manage. An owner or admin reads the whole workspace.

A token stops working when it is revoked, or when its person is archived, removed or given a lower role.

## Scopes

A new token is read only. Choose more scopes when you create it. The form lists only the scopes your role may hold.

| Scope          | What it allows                                                                                                                    |
| -------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| reports:read   | Each GET endpoint.                                                                                                                |
| rates:read     | Adds billable rates, fees and billable amounts where the person's role sees them in the app. Cost is not returned with any scope. |
| people:read    | Adds other people's emails, for an owner or admin.                                                                                |
| time:write     | Creates, changes and deletes time entries, and starts and stops timers.                                                           |
| projects:write | Projects, tasks, and user and task assignments. Owner, admin and manager.                                                         |
| clients:write  | Clients. Owner, admin and manager.                                                                                                |
| people:write   | People, billable rates and roles. Owner and admin.                                                                                |

## Tokens in the URL

A token in the access_token query parameter is refused with 401. An owner or admin can turn on **Accept API tokens in the URL (for older Harvest integrations)** in **Settings**, **API tokens**. Then a token in the URL works for GET requests only. A token in a URL can end up in server logs, browser history and proxies, so send the header when your client allows it. The account_id query parameter is accepted in place of the Harvest-Account-Id header.
