Campaigns API
Campaigns define what a lead looks like, how it is routed and which providers can receive it. Base URL: https://api.pingdex.io/api/v1. Every endpoint on this page needs the campaigns:manage scope.
| Method | Path | Purpose |
|---|---|---|
GET |
/campaigns |
List campaigns. |
POST |
/campaigns |
Create a campaign. |
GET |
/campaigns/{campaign} |
Show a campaign. |
PUT |
/campaigns/{campaign} |
Replace a campaign. |
PATCH |
/campaigns/{campaign} |
Replace a campaign. PATCH behaves exactly like PUT. |
For background, see Campaigns, Lead schema and Routing and eligibility.
All examples assume:
export PINGDEX_API_KEY="pdx_example_0123456789abcdef"The campaign object
Section titled “The campaign object”Every endpoint on this page returns this object, or an array of it.
| Field | Type | Description |
|---|---|---|
id |
string (UUID) | Campaign identifier. |
name |
string | Campaign name. |
description |
string or null | Optional description. |
enabled |
boolean | Whether the campaign accepts new leads. |
routing_strategy |
string | highest_bid or priority. |
schema |
array | The schema fields that leads must satisfy. Empty when the campaign has no schema. |
providers |
array | The assigned providers, in priority order. |
Each item in providers:
| Field | Type | Description |
|---|---|---|
id |
string (UUID) | Provider identifier. |
name |
string | Provider name. |
quotes |
boolean | true when the provider’s integration has a quote leg. |
enabled |
boolean | Whether the provider itself is enabled. |
priority |
integer | Position in the assignment, starting at 1. |
{ "id": "3e1a7c52-9b04-4d68-a2f1-6c8d0e5b7a93", "name": "Remortgage leads", "description": "Remortgage enquiries from the website form.", "enabled": true, "routing_strategy": "highest_bid", "schema": [ { "name": "email", "type": "string", "required": true }, { "name": "property_value", "type": "integer", "required": true }, { "name": "marketing_consent", "type": "boolean", "required": false } ], "providers": [ { "id": "7d2f4a10-6b3e-4c91-8a5d-0e1f2a3b4c5d", "name": "Northwind Mortgages", "quotes": true, "enabled": true, "priority": 1 }, { "id": "9a8b7c6d-5e4f-4a3b-9c2d-1e0f9a8b7c6d", "name": "Fabrikam Home Loans", "quotes": true, "enabled": true, "priority": 2 } ]}List campaigns
Section titled “List campaigns”GET /campaignsReturns every campaign in your account, ordered by name. The body is a JSON array. It is not paginated and has no envelope.
Scope: campaigns:manage
Parameters: none.
| Status | Meaning |
|---|---|
200 |
An array of campaign objects. Empty when you have none. |
401 |
Missing, invalid or expired token. |
403 |
The token does not have campaigns:manage. |
curl https://api.pingdex.io/api/v1/campaigns \ --header "Authorization: Bearer $PINGDEX_API_KEY" \ --header "Accept: application/json"Create a campaign
Section titled “Create a campaign”POST /campaignsCreates a campaign and, optionally, assigns providers to it in one step.
Scope: campaigns:manage
| Field | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | Up to 255 characters. |
routing_strategy |
string | Yes | highest_bid or priority. |
description |
string or null | No | Up to 2000 characters. An empty string is stored as null. |
enabled |
boolean | No | Defaults to false. A campaign that is not enabled refuses new leads. |
schema |
array or null | No | Up to 100 schema fields. Defaults to none. |
provider_ids |
array of UUIDs or null | No | Provider identifiers in priority order. The first has priority 1. Defaults to none. |
Fields that are not listed are ignored.
Schema fields
Section titled “Schema fields”Each item in schema is an object with all three properties:
| Property | Type | Rules |
|---|---|---|
name |
string | Required. Up to 64 characters. Must match ^[A-Za-z_][A-Za-z0-9_]*$: a letter or underscore first, then letters, digits or underscores. Names must be unique within the campaign. |
type |
string | Required. One of string, integer, number, boolean. |
required |
boolean | Required. Whether leads must include the field. |
Validation of provider_ids
Section titled “Validation of provider_ids”- Every identifier must be a UUID.
- An identifier cannot appear twice.
- Every provider must belong to your account.
- Every provider must suit the routing strategy. A
highest_bidcampaign accepts only providers with a quote leg (quotesistrue). Aprioritycampaign accepts only commit-only providers.
All checks run before anything is saved. If any check fails, the campaign is not created.
Responses
Section titled “Responses”| Status | Meaning |
|---|---|
201 |
Created. The body is the campaign object. |
401 |
Missing, invalid or expired token. |
403 |
The token does not have campaigns:manage. |
422 |
Validation failed. See Errors. |
Example 422 for a bad strategy and a bad schema field:
{ "message": "The selected routing strategy is invalid. (and 2 more errors)", "errors": { "routing_strategy": ["The selected routing strategy is invalid."], "schema.0.name": ["The schema.0.name field format is invalid."], "schema.0.type": ["The selected schema.0.type is invalid."] }}Example
Section titled “Example”curl https://api.pingdex.io/api/v1/campaigns \ --request POST \ --header "Authorization: Bearer $PINGDEX_API_KEY" \ --header "Content-Type: application/json" \ --header "Accept: application/json" \ --data '{ "name": "Remortgage leads", "description": "Remortgage enquiries from the website form.", "enabled": true, "routing_strategy": "highest_bid", "schema": [ { "name": "email", "type": "string", "required": true }, { "name": "property_value", "type": "integer", "required": true }, { "name": "marketing_consent", "type": "boolean", "required": false } ], "provider_ids": [ "7d2f4a10-6b3e-4c91-8a5d-0e1f2a3b4c5d", "9a8b7c6d-5e4f-4a3b-9c2d-1e0f9a8b7c6d" ] }'Show a campaign
Section titled “Show a campaign”GET /campaigns/{campaign}Returns one campaign.
Scope: campaigns:manage
| Parameter | In | Type | Description |
|---|---|---|---|
campaign |
path | string (UUID) | The campaign identifier. |
| Status | Meaning |
|---|---|
200 |
The campaign object. |
401 |
Missing, invalid or expired token. |
403 |
The token does not have campaigns:manage. |
404 |
No campaign with this identifier in your account. |
curl https://api.pingdex.io/api/v1/campaigns/3e1a7c52-9b04-4d68-a2f1-6c8d0e5b7a93 \ --header "Authorization: Bearer $PINGDEX_API_KEY" \ --header "Accept: application/json"Replace a campaign (PUT)
Section titled “Replace a campaign (PUT)”PUT /campaigns/{campaign}Replaces the campaign’s fields and its provider assignment in a single transaction. If any validation fails, nothing changes.
Scope: campaigns:manage
Path parameters
Section titled “Path parameters”| Parameter | Type | Description |
|---|---|---|
campaign |
string (UUID) | The campaign identifier. |
The same body and the same rules as create a campaign. name and routing_strategy are required.
What happens to a field you leave out:
| Omitted field | Result |
|---|---|
description |
Set to null. |
enabled |
Set to false. The campaign stops accepting leads. |
schema |
Set to an empty list. |
provider_ids |
Every provider assignment is removed. |
Sending provider_ids replaces the assignments with exactly that list, in that order. Sending [] or null also clears them.
Changing the schema does not alter leads that already exist. A lead is validated against the schema that is current when it is submitted.
Responses
Section titled “Responses”| Status | Meaning |
|---|---|
200 |
Updated. The body is the campaign object. |
401 |
Missing, invalid or expired token. |
403 |
The token does not have campaigns:manage. |
404 |
No campaign with this identifier in your account. |
422 |
Validation failed. |
Example
Section titled “Example”Read the campaign, then send back the whole object with the change you want. This example disables the campaign while keeping everything else.
curl https://api.pingdex.io/api/v1/campaigns/3e1a7c52-9b04-4d68-a2f1-6c8d0e5b7a93 \ --request PUT \ --header "Authorization: Bearer $PINGDEX_API_KEY" \ --header "Content-Type: application/json" \ --header "Accept: application/json" \ --data '{ "name": "Remortgage leads", "description": "Remortgage enquiries from the website form.", "enabled": false, "routing_strategy": "highest_bid", "schema": [ { "name": "email", "type": "string", "required": true }, { "name": "property_value", "type": "integer", "required": true }, { "name": "marketing_consent", "type": "boolean", "required": false } ], "provider_ids": [ "7d2f4a10-6b3e-4c91-8a5d-0e1f2a3b4c5d", "9a8b7c6d-5e4f-4a3b-9c2d-1e0f9a8b7c6d" ] }'The response lists the providers in priority order. provider_ids in the request is the only input for assignments: the providers array you read back is output, so convert it to a list of id values when you replay it.
Replace a campaign (PATCH)
Section titled “Replace a campaign (PATCH)”PATCH /campaigns/{campaign}PATCH uses the same handler, the same body, the same validation and the same responses as PUT. Despite the verb, it is not a partial update.
Scope: campaigns:manage
A PATCH that sends only {"name": "New name"} returns 422 because routing_strategy is missing. A PATCH that includes both required fields but leaves out enabled disables the campaign and clears its schema and providers, exactly as PUT would.
curl https://api.pingdex.io/api/v1/campaigns/3e1a7c52-9b04-4d68-a2f1-6c8d0e5b7a93 \ --request PATCH \ --header "Authorization: Bearer $PINGDEX_API_KEY" \ --header "Content-Type: application/json" \ --header "Accept: application/json" \ --data '{ "name": "Remortgage leads (UK)", "description": "Remortgage enquiries from the website form.", "enabled": true, "routing_strategy": "highest_bid", "schema": [ { "name": "email", "type": "string", "required": true }, { "name": "property_value", "type": "integer", "required": true }, { "name": "marketing_consent", "type": "boolean", "required": false } ], "provider_ids": [ "7d2f4a10-6b3e-4c91-8a5d-0e1f2a3b4c5d", "9a8b7c6d-5e4f-4a3b-9c2d-1e0f9a8b7c6d" ] }'Because the two verbs are equivalent, pick one and use it consistently. If you want to avoid accidental resets, build the request from a fresh GET every time.
Common errors
Section titled “Common errors”| Key | Message | Cause |
|---|---|---|
name, routing_strategy |
The name field is required., The routing strategy field is required. |
A required field is missing. |
routing_strategy |
The selected routing strategy is invalid. |
Not highest_bid or priority. |
schema |
The schema field must not have more than 100 items. |
More than 100 schema fields. |
schema.N.name |
The field name is already used. |
A duplicate schema field name. |
provider_ids |
A provider can only be assigned once. |
A repeated identifier. |
provider_ids |
Select providers from this account. |
An identifier is not one of your providers. |
provider_ids |
Each provider must match the campaign routing strategy. |
A quote provider on priority, or a commit-only provider on highest_bid. |
See Errors for the full response shapes.