---
title: "Authentication and workspaces"
description: "Learn how to authenticate API requests with a key and name the company a call is for."
---

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

# Authentication and workspaces

Every request to the Certinvo API carries an API key. This page shows the key format, how one key picks
Sandbox or Live, and how to name a company when one key reaches several.

## Base URL

All requests go to one base URL, over HTTPS:

```text
https://api.certinvo.com
```

Send your key as a Bearer token in the standard `Authorization` header.

## Key format

Every key starts with a prefix that names its environment and type:

```text
cvo_<environment>_<type>_<random>
```

| Part | Values | Meaning |
|---|---|---|
| Environment | `live` or `test` | `test` reaches Sandbox. `live` reaches production. |
| Type | `sk` | A server key. Every key issued today is an `sk` key. |
| Random | 32 characters | Random base64url characters. |

Example keys:

- Live server key: `cvo_live_sk_0123456789abcdef0123456789abcdef`
- Sandbox server key: `cvo_test_sk_0123456789abcdef0123456789abcdef`

The prefix decides the environment. So your code uses the same base URL for Sandbox and Live.

## Companies

A **company** is one invoicing entity of a workspace, in Sandbox or Live. All invoice data belongs to a
company. One workspace can hold many companies, so a platform can serve each of its customers as a company of its
own.

### Company keys

A company key belongs to one company. You send nothing else:

```bash
curl -X GET "https://api.certinvo.com/v1/invoices" \
  -H "Authorization: Bearer cvo_live_sk_..."
```

### Workspace keys

A workspace key reaches every company of its workspace. Name the company in the `Certinvo-Company` header:

```bash
curl -X GET "https://api.certinvo.com/v1/invoices" \
  -H "Authorization: Bearer cvo_live_sk_..." \
  -H "Certinvo-Company: 3f2b8c1e-7d4a-4e6b-9c0d-5a1f2e3b4c5d"
```

The company id is a UUID. You get 404 `unknown_company` when the id is not a UUID, or when no company of your
workspace has it.

If a workspace key calls a company route without the `Certinvo-Company` header, the API answers 400:

```json
{
  "error": {
"code": "company_required",
"message": "This key holds more than one company. Name the company this call is for: Certinvo-Company: <company id>",
"request_id": "req_3f9a12bc0e5d4a71"
  }
}
```

## Limit a key

When you create a key in the console, you can give it three limits. Each is optional.

| Limit | What it does | A call outside it gets |
|---|---|---|
| **Expires** | The key stops working on that date: in 30 days, 90 days or 1 year. | 401 `invalid_credentials` |
| **Read only** | The key may only read: `GET` and `HEAD`. | 403 `key_read_only` |
| **Allowed IP addresses** | The key works only from these IP addresses or CIDR ranges, up to 20. | 401 `invalid_credentials` |

A key from outside its addresses, or past its date, gets the same answer as a wrong key. A limit cannot be
changed later: create a new key with the limits you want, move your integration to it, then revoke the old one.

## Keep your keys safe

- Store keys in environment variables or a secrets vault. Never commit them to version control.
- Give each integration its own key. You can then revoke one without stopping the others.
- Give each key only what it needs: read only for a report, your servers' IP addresses, and an expiry date.
- If a key leaks, revoke it at once and issue a new one. You do both in the Certinvo console.

## See also

- [Quickstart](/start/quickstart): check your first invoice with your key.
- [Work in Sandbox](/how-to/workspaces/work-in-sandbox): test without touching live data.
- [Set up a platform partner](/how-to/workspaces/set-up-a-platform-partner): serve your customers as companies.
- [API error codes](/reference/api-error-codes): every error the API returns.

Source: https://docs.certinvo.com/start/authentication-and-workspaces/index.mdx
