Authentication
Woodpecker API follows a unified authentication mechanism across all endpoints, but when managing multiple accounts, you need to consider the company context. Your API requests may operate at different levels:
- HQ account (your main company account)
- Client accounts (individual accounts you manage)
This guide covers general authentication and multi-account management using the HQ API key and the master API key.
Generating an API key
To authenticate requests, you must first generate an API key. Click here to go to the API keys view of your HQ. You can also follow the instructions below; the process is the same for your HQ account and client accounts:
- Log into the Woodpecker account where you want to generate an API key (either your HQ account or a client account)
- Go to the Marketplace in the top-right corner → Integrations → 'API keys'
- Click
Create a key
- You can add a label to each created key to describe what integration it is being used for
API keys are user-specific, meaning each user only sees their own keys. Keep them private and do not share them with others.
Authenticating requests
The base URL is:
https://api.woodpecker.co/rest
All requests need to be authenticated using an x-api-key
header. Try the request below, making sure to replace YOUR_API_KEY
with your actual key. Note the difference in the response when using an Agency HQ API key versus a client account API key or master API key.
curl --request GET \
--url "https://api.woodpecker.co/rest/v1/me" \
--header "x-api-key: {YOUR_API_KEY}"
Company context
When working across multiple accounts, you have two ways to authenticate requests:
- Using a dedicated API key for each account - generate a separate API key for each client, with the key operating only within given account. (Use rest/v2/agency/companies/{cid}/api_keys to generate client keys via API)
- Using the HQ API key with
x-company-id
header - send requests on behalf of different accounts without switching API keys. Include thex-company-id
header to specify which account's data you are accessing. This is described further below.
Use the HQ API key for managing multiple accounts. For endpoints that interact with specific accounts, either use a client's API key or specify x-company-id.
Use the HQ API key for /agency
endpoints. To access the Cold Email API for a specific client, choose one of the methods above.
Using master API key
The HQ API key allows managing multiple accounts with a single key. To make use of this functionality, you need:
- HQ API key - how to generate it
- Client account ID (referred to as
company
in API terminology). You can retrieve it using GET /companies
Example requests
Lets consider an example where you want to retrieve mailboxes connected to company ID 123. You can:
- Use an API key generated for this company
curl --request GET \
--url "https://api.woodpecker.co/rest/v2/mailboxes" \
--header "x-api-key: API_KEY_COMPANY_123"
- Use the HQ API key together with the
x-api-key
header
curl --request GET \
--url "https://api.woodpecker.co/rest/v2/mailboxes" \
--header "x-api-key: HQ_API_KEY" \
--header "x-company-id: 123"
- A similar request without the
x-api-key
header will return mailboxes connected to your HQ account
curl --request GET \
--url "https://api.woodpecker.co/rest/v2/mailboxes" \
--header "x-api-key: HQ_API_KEY"
- You can also use an
/agency
endpoint that retrieves email accounts for a specific company
curl --request GET \
--url "https://api.woodpecker.co/rest/v2/agency/companies/123/email_accounts" \
--header "x-api-key: HQ_API_KEY"
Error codes
- 400
- 401
- 403
- 404
- 409
- 500
x-company-id
provided but not numeric
{
"title": "Bad request",
"status": 400,
"detail": "X-Company-Id header value must be a number but is not",
"timestamp": "2025-03-05 17:57:00"
}
Please review whether you are using a correct API key, whether it is added to the header and whether your subscription grants API access.
{
"title": "Unauthorized",
"status": 401,
"detail": "Invalid api key" | "No API addon" | "Upgrade your plan",
"timestamp": "2025-03-05 17:57:00"
}
x-company-id
provided but it's not the key from the main agency account
Status: 403
Body: none
x-company-id
provided but company does not exist within the agency from which the HQ key originates
{
"title": "Not Found",
"status": 404,
"detail": "Company not found",
"timestamp": "2025-03-05 17:57:00"
}
x-company-id
provided but company is inactive
{
"title": "Conflict",
"status": 409,
"detail": "Company is inactive",
"timestamp": "2025-03-05 17:57:00"
}
Unknown error, please try again later
{
"title": "Internal Server Error",
"status": 500,
"detail": "An unexpected error has occurred. Please try again later.",
"timestamp": "2025-03-05 17:57:00"
}
Body schema
Field | Type | Description |
---|---|---|
title | string | A short title describing the error |
status | integer | The HTTP status code |
detail | string | A detailed message explaining the error |
timestamp | string | The timestamp when the error occurred, YYYY-MM-DD HH:MM:SS UTC |