Get list of email accounts assigned to the client
This endpoint returns list of the email accounts linked to the client. By using this feature you can GET
information including
the type of email account, provider, and additional information such as error status, from name,
IMAP ID, and the number of running campaigns associated with each account.
For further actions, such as adding, refer to the related /companies endpoints.
Request
Endpoint
GET https://api.woodpecker.co/rest/v2/agency/companies/{company_id}/email_accounts/
Headers
x-api-key: {YOUR_API_KEY}
For details on how to authenticate your requests, please see the authentication guide.
Parameters
Parameter | Required | Description |
---|---|---|
company_id | Yes | Company ID. This parameter is required. |
Request sample
Get list of email accounts
- cURL
- Python
- Java
- Node.js
curl --request GET \
--url "https://api.woodpecker.co/rest/v2/agency/companies/{company_id}/email_accounts" \
--header "x-api-key: {YOUR_API_KEY}"
import requests
def get_email_accounts(company_id):
url = f"https://api.woodpecker.co/rest/v2/agency/companies/{company_id}/email_accounts"
headers = {
"x-api-key": "{YOUR_API_KEY}"
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
return response.json()
else:
raise Exception(f"GET request failed: {response.status_code}, {response.text}")
if __name__ == "__main__":
try:
company_id = 123 # Example company ID
data = get_email_accounts(company_id)
print("GET response:", data)
except Exception as e:
print("Error:", e)
public class WoodpeckerApiClient {
private static final String API_KEY = "{YOUR_API_KEY}";
public static void main(String[] args) {
int companyId = 123; // Example company ID
getEmailAccounts(companyId);
}
public static void getEmailAccounts(int companyId) {
try {
String url = "https://api.woodpecker.co/rest/v2/agency/companies/" + companyId + "/email_accounts";
java.net.http.HttpClient client = java.net.http.HttpClient.newHttpClient();
java.net.http.HttpRequest request = java.net.http.HttpRequest.newBuilder()
.uri(new java.net.URI(url))
.header("x-api-key", API_KEY)
.GET()
.build();
java.net.http.HttpResponse<String> response = client.send(request, java.net.http.HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 200) {
System.out.println("GET response: " + response.body());
} else {
System.err.println("GET request failed: " + response.statusCode());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
const axios = require('axios');
async function getEmailAccounts(companyId) {
const url = `https://api.woodpecker.co/rest/v2/agency/companies/${companyId}/email_accounts`;
const headers = {
'x-api-key': '{YOUR_API_KEY}'
};
try {
const response = await axios.get(url, { headers });
console.log('GET response:', response.data);
} catch (error) {
console.error('GET request failed:', error.response ? error.response.status : error.message);
}
}
(async () => {
const companyId = 123; // Example company ID
await getEmailAccounts(companyId);
})();
Response
Response examples
- 200
- 400
- 401
- 404
- 500
A list of email accounts used by a specific agency client.
{
"content": [
{
"id": 0,
"type": "IMAP",
"details": {
"email": "example@email.com",
"provider": "provider1",
"error": "string",
"from_name": "string",
"imap_id": 0,
"running_campaigns": 2
}
},
{
"id": 1,
"type": "SMTP",
"details": {
"email": "example@email.com",
"provider": "provider1",
"error": "string",
"from_name": "string",
"imap_id": 0,
"running_campaigns": 0
}
}
]
}
Body schema
Field | Type | Description |
---|---|---|
content | JSON object | List of email accounts |
└─id | integer | Email account ID |
└─type | string | Type of email account |
└─details | JSON object | Object with email account details |
└─email | string | Email account address |
└─provider | string | Email account provider name |
└─error | string | Error details |
└─from_name | string | From name |
└─imap_id | integer | IMAP ID |
└─running_campaigns | integer | Number of running campaigns |
Invalid request parameters or malformed request syntax.
{
"title": "Bad request",
"status": 400,
"detail": "string",
"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 |
An issue with authorization. Please review the authorization guide
{
"title": "Unauthorized",
"status": 401,
"detail": "Invalid api key",
"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 |
Please review the request URL.
{
"title": "Not Found",
"status": 404,
"detail": "Requested resource does not exist",
"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 |
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 |