# Post a record

> POST /api/v1/engine/leads: one new record per request, to your own campaign.

```http
POST /api/v1/engine/leads
```

- Post each record once, as you collect it, with the values your campaign's page shows on every record.
- Every post is a new record. A post never updates or names a record ICON already has, so a request that sends any of these is refused: `icon_lead_id`, `lead_id`, `source_icon_lead_id`, `source_lead_id`, `search_lead_id`, `icon_search_lead_id`, `icon_result_id`.
- Send the person's own IP address, from when they opted in, as `tracking.ip_address` when you have it, never your server's. Without it, ICON records the address your post came from and marks it as your server's, not the person's.
- Send the consent certificates you hold for the record. When one is required for this campaign (by where it sends records, by your supplier account or by the campaign itself; your campaign's page lists each under What ICON checks), a record without a valid one is refused before it goes anywhere.
- Optional: send your own id for each record as `supplier_record_id`, text of up to 200 characters, a new one for each record. You don't need one: ICON creates its own id for every record it receives. A value that is not text of 1 to 200 characters is refused (HTTP 400 `INVALID_FIELD`, `supplier_record_id_invalid`) and nothing is stored. How ICON answers a record sent again with the same id is under Retries and repeats.

## The request

| Part | What to send |
| --- | --- |
| Header | `X-API-Key: <your API key>` (or `Authorization: Bearer <your API key>`), and `Content-Type: application/json`. |
| Your campaign | The values your campaign's page lists under "Send these on every record": your campaign (by its code, or by `icon_campaign_id` with `icon_offer_id`) and your account (`icon_affiliate_id`). |
| The person | `lead.personal`, `lead.address`, `lead.education`, `lead.background`: the fields your campaign's page lists. Formats are in the [field dictionary](https://developers.iconroute.io/fields/). |
| Their IP address | `tracking.ip_address`: the person's own address from when they opted in, when you have it. |
| Consent certificates | See below. |
| Test flag | `icon_is_test_lead: true` on a test record. See [Testing](#testing). |

```bash
curl -X POST 'https://iconroute.io/api/v1/engine/leads' \
  -H "X-API-Key: $ICON_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "icon_campaign_id": "6f1c2d3e-4a5b-4c6d-8e9f-0a1b2c3d4e5f",
  "icon_offer_id": "0b7e4a2c-9d8f-4e1a-b2c3-d4e5f6a7b8c9",
  "icon_affiliate_id": "3c9d8e7f-1a2b-4c3d-9e8f-7a6b5c4d3e2f",
  "lead": {
    "personal": {
      "first_name": "Ada",
      "last_name": "Lovelace",
      "email": "ada.lovelace@mail.test",
      "phone": "6025552368",
      "date_of_birth": "1990-04-07"
    },
    "address": {
      "address_line_1": "123 N Main St",
      "city": "Phoenix",
      "state": "AZ",
      "zip_code": "85004"
    },
    "education": {
      "education_level": "bachelors",
      "high_school_graduation_year": "2008",
      "start_timeline": "1_3_months",
      "learning_preference": "online"
    },
    "background": {
      "military_affiliation": "none",
      "us_citizen": "yes"
    }
  },
  "tracking": {
    "ip_address": "203.0.113.9"
  },
  "universal_leadid": "3f2c7a1e-5b6d-4e8f-9a0b-1c2d3e4f5a6b",
  "trusted_form_cert_url": "https://cert.trustedform.com/0123456789abcdef0123456789abcdef01234567",
  "icon_is_test_lead": true
}'
```

## Consent certificates

| Certificate | Field | Format | Refused without it as |
| --- | --- | --- | --- |
| Jornaya LeadiD | `universal_leadid` | The 36-character LeadiD token (8-4-4-4-12 hexadecimal), not all zeros. | `JORNAYA_MISSING` |
| TrustedForm certificate | `trusted_form_cert_url` | The full certificate URL: https://cert.trustedform.com/ followed by the 40-character certificate id. | `TRUSTEDFORM_MISSING` |

A record is refused for a missing certificate only when your campaign's buyer requires it. Send every certificate you hold for the record. See [Consent and TCPA](https://developers.iconroute.io/consent/) for the other keys ICON reads them from.

## Testing

- A record sent with `icon_is_test_lead: true` is a test record. A test record is checked like any record: your key, the values that name your campaign, its required fields, consent, eligibility and the duplicate check. It is compared with the records already held but never added to them, so it can be answered `DUPLICATE` like a live one. If it passes, it is held: never sent on, not counted against your campaign's caps and not paid, and answered `TEST_LEAD_HELD`.
- While your campaign is in testing, **every** record is held this way, with or without the flag. Your campaign's page says whether it is; your account manager turns testing off when the campaign goes live.

## Answers

Every answer carries `code` and `retryable`. Branch on `code`: the finer values below come in `reason`, `error` or `disposition.reason_code`, as shown. These are the answers you are most likely to meet; [Standard responses](https://developers.iconroute.io/responses/) lists every code.

| code | HTTP | status | Send again? | When |
| --- | --- | --- | --- | --- |
| `ACCEPTED` | 200 | accepted | no | The record was accepted. |
| `SAVED` | 200 | saved | no | The post did not name its campaign completely (a campaign code, or `icon_campaign_id` with `icon_offer_id`), so the record was only stored, not posted. It cannot be completed later: a post that names it again is refused as `supplier_key_new_records_only`. Post the full record again, with the values your campaign's page lists. |
| `PENDING` | 200, 202 | pending | no | The record was received and its final answer is not in yet. Do not send it again. `reason: "supplier_record_unresolved"`: A repeat of a `supplier_record_id` whose first answer was not final (HTTP 202, `replay: true`). It is not created twice; ICON resolves it. |
| `TEST_LEAD_HELD` | 200 | held | no | A test record: it was sent with `icon_is_test_lead: true`, or your campaign is in testing. A test record is checked like any record: your key, the values that name your campaign, its required fields, consent, eligibility and the duplicate check. It is compared with the records already held but never added to them, so it can be answered `DUPLICATE` like a live one. If it passes, it is held: never sent on, not counted against your campaign's caps and not paid, and answered `TEST_LEAD_HELD`. |
| `AUTH_REQUIRED` | 401 | invalid | no | The post carried no API key. Every post to your campaign needs its key. `reason: "missing_api_key"`: No key was sent. |
| `AUTH_INVALID` | 401 | invalid | no | The key is unknown or revoked, or it was sent somewhere other than a header. `reason: "invalid_api_key"`: ICON does not know this key, or it was revoked. `reason: "supplier_key_header_only"`: The key was in the URL. Revoke it and create a new one. `error: "supplier_key_header_only"`: The key was in the body. Revoke it and create a new one. |
| `FORBIDDEN` | 403 | invalid | no | The key may not make this post. `reason: "supplier_key_required"`: The post to your campaign carried a key that is not your campaign's supplier key (an affiliate key, say). `reason: "ip_not_allowed_for_key"`: The post came from an address outside the key's IP allowlist. `reason: "supplier_key_new_records_only"`: The post named a record ICON already has. Send new records only. `reason: "campaign_outside_scope"`: The post named, by `icon_campaign_id`, a campaign that is not yours. `reason: "offer_outside_scope"`: The post named, by `icon_offer_id`, an offer that is not yours. `error: "Campaign or offer is outside supplier scope"`: The post named, by campaign code, a campaign that is not yours. `reason: "campaign_not_allowed_for_key"`: The post named, by `icon_campaign_id`, another of your campaigns. A key posts to its own campaign only. `reason: "supplier_key_campaign_invalid"`: The post named, by campaign code, another of your campaigns. A key posts to its own campaign only. `error: "campaign_outside_affiliate"`: The campaign named is not your account's (when ICON checks that every post names its campaign and account). `error: "affiliate_mismatch"`: `icon_affiliate_id` is not your key's account (when ICON checks that every post names its campaign and account). |
| `NOT_FOUND` | 404 | invalid | no | The values that name your campaign did not match a campaign. Copy them from your campaign's page. |
| `OFFER_UNAVAILABLE` | 410 | rejected | no | Your campaign, or where it sends records, is paused or not live. Records sent now are not accepted. |
| `REQUIRED_FIELD_MISSING` | 200, 400 | invalid | no | A required field is missing; `field` names it, and `level` names who requires it: `offer` (where the campaign sends records), `affiliate` (your supplier account) or `campaign` (this campaign). `error: "campaign_required"`: The post asks to be posted (with a TCPA id, or `context: "blind_submit"` beside an offer id) without naming its campaign (HTTP 400, when ICON checks that every post names its campaign and account). An offer id alone is only stored (`SAVED`). `error: "affiliate_required"`: The post does not send `icon_affiliate_id` (HTTP 400, when ICON checks that every post names its campaign and account). |
| `INVALID_FIELD` | 200, 400 | invalid | no | A field has a value ICON does not accept; `field` names it. `reason: "supplier_record_id_invalid"`: `supplier_record_id` is not text of 1 to 200 characters (HTTP 400). Nothing was stored. |
| `CONSENT_REQUIRED` | 200 | invalid | no | The record does not carry the consent required where the campaign sends records. |
| `JORNAYA_MISSING` | 200 | invalid | no | A Jornaya LeadiD is required for this campaign and the record has no valid one; `level` names who requires it (`offer`, `affiliate` for your supplier account, or `campaign`). |
| `TRUSTEDFORM_MISSING` | 200 | invalid | no | A TrustedForm certificate is required for this campaign and the record has no valid one; `level` names who requires it (`offer`, `affiliate` for your supplier account, or `campaign`). |
| `NOT_ELIGIBLE` | 200 | rejected | no | The record is outside what this campaign takes, for example a state or ZIP code it does not accept, or outside its hours; `level` names whose check refused it (`offer`, `affiliate` for your supplier account, or `campaign`). |
| `CAP_REACHED` | 200 | rejected | no | Your campaign has taken all the records it can for now. |
| `DUPLICATE` | 200, 409 | rejected | no | The person is already on record. The record is refused and not paid. `disposition.reason_code: "supplier_duplicate"`: The person is already on record for your campaign's buyer. |
| `BUYER_REJECTED` | 200 | rejected | no | The record passed ICON's checks and the list it goes to refused it. |
| `RATE_LIMITED` | 429 | failed | yes, later | The key is over its limit. Wait the seconds in the `Retry-After` header, then send it again. |
| `UNAVAILABLE` | 200, 503 | failed | yes, later | ICON could not complete the checks; nothing was delivered. Send the record again later. `reason: "api_key_lane_unverifiable"`: ICON could not read the key just now (HTTP 503). Send the record again. `disposition.reason_code: "supplier_dupe_in_flight"`: The same person is on the way in to your campaign's buyer in another record right now. Send it again later: the new record is checked against how that one ended. `disposition.reason_code: "supplier_dupe_unavailable"`: The duplicate check could not run, so the record was not posted. `disposition.reason_code: "supplier_requirements_unavailable"`: ICON could not read this campaign's checks just now (HTTP 503), so the record was not posted. Send it again. `disposition.reason_code: "supplier_dupe_window_missing"`: Your campaign is not set up to check records yet. Your account manager sets it up. `reason: "supplier_record_in_flight"`: A repeat of a `supplier_record_id` whose first post is still being processed (HTTP 503, `replay: true`). Send it again shortly; it is not created twice. |
| `INTERNAL_ERROR` | 500 | failed | no | Something failed on ICON's side. Do not resend it as is; tell your account manager the time and the answer's `request_id`. |



## Check before you post

- `POST /api/v1/engine/dupe-check` with the same key, in a header; the key's IP allowlist applies. It asks whether ICON would refuse the person as already on record, before you post them.
- Send the person's `phone`, `email` or both: raw, or as `hashed: { "phone": …, "email": … }`, each the lower-case hex SHA-256 of the normalized form, as the Developer Center's duplicate pre-check page publishes it.
- Do not send `offer_id`: the key checks its own campaign, and a request with one is refused (HTTP 400 `INVALID_FIELD`).
- The answer is `duplicate_likely: true` or `false`, nothing more. `false` is not a promise: your post is checked again.
- HTTP 503 `UNAVAILABLE` means the check could not run, including while your campaign's duplicate rule is not set up yet; post the record or try again later.
- While ICON is trying the duplicate check out, before it refuses anything, every answer that is not a 503 is `duplicate_likely: false`. While ICON has the check switched off, for every supplier, the endpoint answers HTTP 404.
- It has its own limit: 30 checks per minute per key, in bursts of up to 10.

## Retries and repeats

- Read `code` in the answer, not the HTTP status: a decision about a record usually comes with HTTP 200, and the same code can come with more than one HTTP status.
- Send a record again only when the answer says `retryable: true`. Wait first: after `RATE_LIMITED`, the `Retry-After` header says how many seconds; otherwise wait 1, then 2, then 4 seconds, and stop after three tries.
- A record sent again with the same `supplier_record_id` on your campaign is not created twice, and its answer carries `"replay": true`. When the first post's answer was final, it is that answer again. While the first post is still being processed, it is HTTP 503 `UNAVAILABLE` (`supplier_record_in_flight`, retryable): send it again shortly. If the first answer was not final and 5 minutes have passed since ICON received the record, it is HTTP 202 `PENDING` (`supplier_record_unresolved`): do not send it again, ICON resolves it. A repeat is never checked or posted a second time, even after a retryable answer.
- Without `supplier_record_id`, ICON keeps every post it answers as its own record, so a record you send again, even after a retryable answer, is stored again. That is intended after `supplier_dupe_in_flight`: the new record is checked against how the other one ended.
- If a post got no answer at all (a network error or your own timeout), ICON may have received it; check with your account manager before you send it again.
- Keep each key under 120 posts per minute. Posts beyond that may be answered HTTP 429 `RATE_LIMITED`.
