Integration specification
The integration is the reviewable definition of how Pingdex talks to a buyer. It is a JSON object that describes an ordered list of request legs.
Structure
Section titled “Structure”The integration object has exactly one key, legs. Any other root key is rejected.
{ "legs": [ /* one or two leg objects */ ]}Each leg has these keys. No others are allowed.
| Key | Required | Description |
|---|---|---|
name |
Yes | A stable identifier for the leg. |
role |
Yes | quote or commit. |
request |
Yes | The HTTP request Pingdex sends. |
response |
Quote: yes. Commit: no. | How Pingdex reads the buyer’s reply. |
Leg layout
Section titled “Leg layout”An integration has one or two legs, in one of two shapes:
| Shape | Legs | Dashboard badge |
|---|---|---|
| Commit only | One commit leg. |
Direct post |
| Quote then commit | One quote leg, then one commit leg. |
Ping / post |
The rules that apply:
- There must be exactly one
commitleg, and it must be last. - There may be at most one
quoteleg, and if present it comes before the commit. - Anything else is rejected, for example two commits, a quote on its own, or a commit followed by a quote.
Leg names
Section titled “Leg names”Names key headers, response references and attempt records, so they must stay stable.
- 1 to 64 characters.
- Must match
^[A-Za-z_][A-Za-z0-9_-]*$. Start with a letter or underscore, then use letters, digits, underscores or hyphens. - Unique within the integration.
| Role | Purpose |
|---|---|
quote |
The ping. Asks the buyer for a bid and establishes that the provider is eligible for this lead. |
commit |
The post. Submits the lead to the buyer for commercial acceptance. |
Request
Section titled “Request”| Key | Required | Rules |
|---|---|---|
method |
Yes | POST only. |
url |
Yes | An absolute URL, up to 2,048 characters. Use https. |
encoding |
No | json (the default) or form. |
fields |
Yes | An object of destination to mapping. It must be non-empty. |
Notes on each:
method: Pingdex only sendsPOSTrequests. Other methods are rejected.url: Onlyhttpandhttpsschemes compile, but in production Pingdex only sends tohttpsdestinations on public addresses. At send time, Pingdex also refuses a URL that contains a username, a password or a fragment. See Authentication.encoding:jsonsends a JSON object body.formsendsapplication/x-www-form-urlencoded. Form encoding allows flat destination names and string static values only. See Request mapping.fields: Each key is a destination in the request body and each value is a mapping. There must be at least one field.
Response
Section titled “Response”The response key describes how Pingdex reads the buyer’s reply. It is required on a quote leg and optional on a commit leg. The two forms differ. See Response mapping.
Headers and secrets are not part of the integration
Section titled “Headers and secrets are not part of the integration”The integration never contains header values or secret values. Those are supplied alongside it when you save the provider, in the headers and secrets objects. The integration can only refer to a secret by name. See Authentication.
Examples
Section titled “Examples”All values below are synthetic.
A single post leg. This is a direct post provider, suitable for a campaign that uses priority routing.
{ "legs": [ { "name": "post", "role": "commit", "request": { "method": "POST", "url": "https://buyer.example/post", "encoding": "json", "fields": { "Email": { "type": "field", "source": "payload.email", "transform": "lower" }, "Postcode": { "type": "field", "source": "payload.postcode", "transform": "upper" }, "Source": { "type": "static", "value": "pingdex" }, "ApiKey": { "type": "secret", "secret": "api_token" } } }, "response": { "accepted": "status", "accepted_values": ["Accepted"], "rejected_values": ["Rejected"], "transaction_id": "data.id", "rejection_reason": "data.reason" } } ]}The response on a commit leg is optional. Leave it out if you do not need Pingdex to record commercial acceptance.
A ping quote leg followed by a post commit leg. This is a ping/post provider, suitable for a campaign that uses highest_bid routing. The post sends back a transaction reference taken from the ping response.
{ "legs": [ { "name": "ping", "role": "quote", "request": { "method": "POST", "url": "https://buyer.example/ping", "fields": { "Email": { "type": "field", "source": "payload.email" }, "Postcode": { "type": "field", "source": "payload.postcode" } } }, "response": { "accepted": "accepted", "bid": "bid", "extract": { "transaction_id": "data.transaction_id" } } }, { "name": "post", "role": "commit", "request": { "method": "POST", "url": "https://buyer.example/post", "fields": { "Email": { "type": "field", "source": "payload.email" }, "TransactionId": { "type": "response", "leg": "ping", "source": "transaction_id" } } }, "response": { "accepted": "status", "accepted_values": ["Accepted", true, 1], "rejected_values": ["Rejected", false, 0], "transaction_id": "data.id", "sale_amount": "data.amount", "rejection_reason": "data.reason" } } ]}Common compile errors
Section titled “Common compile errors”When an integration does not compile, the error names the failing path and the reason, for example legs.0.request.fields: empty. The most common causes:
| Error | Cause |
|---|---|
unknown key |
A key that the object does not allow, including any root key other than legs. |
commit leg must be last |
The final leg is not a commit. |
exactly one commit leg is required |
There are no commit legs, or more than one. |
at most one quote leg is permitted |
More than one quote leg. |
legs.N.name: name not allowed or too long |
The leg name breaks the naming rule. |
legs.N.name: duplicate |
Two legs share a name. |
must be POST |
A method other than POST. |
legs.N.request.fields: empty |
A request with no fields. |
See Testing and troubleshooting for more.