Get a company's API keys
Retrieve a paginated list of API keys associated with a specific company. The response will include only the keys created by the requesting user.
Request
Endpoint
GET https://api.woodpecker.co/rest/v2/agency/companies/{company_id}/api_keys
Headers
x-api-key: {YOUR_API_KEY}
For details on how to authenticate your requests, please see the authentication guide.
Parameters
| Parameter | Required | Type | Description | 
|---|---|---|---|
| company_id | Yes | integer | Path parameter - the ID of the company for which the API keys will be returned | 
| page | No | integer | Requested results page (1-based) | 
Request samples
Get list of API keys
- cURL
- Python
- Java
- Node.js
- PHP
curl --request GET \
  --url "https://api.woodpecker.co/rest/v2/agency/companies/{company_id}/api_keys" \
  --header "x-api-key: {YOUR_API_KEY}"
import requests
def get_api_keys(company_id):
  url = f"https://api.woodpecker.co/rest/v2/agency/companies/{company_id}/api_keys"
  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_api_keys(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
    getApiKeys(companyId);
  }
  public static void getApiKeys(int companyId) {
    try {
      String url = "https://api.woodpecker.co/rest/v2/agency/companies/" + companyId + "/api_keys";
      java.net.URL obj = new java.net.URL(url);
      java.net.HttpURLConnection con = (java.net.HttpURLConnection) obj.openConnection();
      con.setRequestMethod("GET");
      con.setRequestProperty("x-api-key", API_KEY);
      int responseCode = con.getResponseCode();
      System.out.println("GET Response Code : " + responseCode);
      if (responseCode == 200) {
        java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(con.getInputStream()));
        String inputLine;
        StringBuilder response = new StringBuilder();
        while ((inputLine = in.readLine()) != null) {
          response.append(inputLine);
        }
        in.close();
        System.out.println("GET response: " + response.toString());
      } else {
        System.err.println("GET request failed: " + responseCode);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
const axios = require('axios');
async function getApiKeys(companyId) {
  const url = `https://api.woodpecker.co/rest/v2/agency/companies/${companyId}/api_keys`;
  const headers = {
    'x-api-key': '{YOUR_API_KEY}'
  };
  try {
    const response = await axios.get(url, { headers });
    // expected response 200
    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 getApiKeys(companyId);
})();
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
$client = new Client([
  'base_uri' => 'https://api.woodpecker.co/rest/v2/',
  'headers'  => ['x-api-key' => getenv('WOODPECKER_API_KEY')],
]);
$companyId = '{COMPANY_ID}';
try {
  $response = $client->get("agency/companies/{$companyId}/api_keys");
  echo $response->getStatusCode(), "\n";
  echo $response->getBody(), "\n";
} catch (RequestException $e) {
  echo "Error: ", $e->getMessage(), "\n";
  if ($e->hasResponse()) {
    echo $e->getResponse()->getBody(), "\n";
  }
}
Response
Response examples
- 200
- 400
- 401
- 404
- 500
A list of API keys. If there no API keys, content will be an empty array.
{
  "content": [
    {
      "api_key": "123456.abcdefg123456hijk987",
      "label": "Custom name"
    },
    {
      "api_key": "123456.123456abcd987efghijk",
      "label": "Custom name 2"
    }
  ],
  "pagination_data": {
    "total_elements": 2,
    "total_pages": 1,
    "current_page_number": 1,
    "page_size": 50
  }
}
Body schema
| Field | Type | Description | 
|---|---|---|
| content | array[object] | Array of API key objects | 
| └─ [].api_key | string | API key | 
| └─ [].label  | string/null | A descriptive name assigned while generating the key | 
| pagination_data | object | Pagination information. See the pagination section | 
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:SSUTC | 
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:SSUTC | 
The requested company does not exists, or the request URL is incorrect
{
  "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:SSUTC | 
Unexpected 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:SSUTC | 
Pagination
The response body contains pagination details. It will support you in navigating through larger datasets.
Use page parameter to view a specific page.
info
Each page contains up to 50 API keys
{
  "content": [],
  "pagination_data": {
    "total_elements": 300,
    "total_pages": 6,
    "current_page_number": 2,
    "page_size": 50
  }
}
| Field | Type | Description | 
|---|---|---|
| pagination_data | object | Pagination information | 
| └─ total_elements | integer | Total number of API keys | 
| └─ total_pages | integer | Total number of available pages | 
| └─ current_page_number | integer | Current page number (1-based) | 
| └─ page_size | integer | Maximum number of items per page |