Import ad results
POST /api/v1/ads/import
The key needs the scope ads:write
Stores ad results for one ad account, up to 2000 rows in a request.
Campaigns, ad sets and ads are created or updated by their external ids, and one set of numbers is kept for each of them and reporting period. Rows are judged one by one: good rows are stored, and a row that cannot be read comes back in errors with its index and the reason. Sending the same rows again changes nothing; a row whose dates overlap an earlier row of the same campaign, ad set or ad replaces it, so no day is counted twice. The currency is required and never guessed, and an account keeps the currency it was created with. A number you leave out is stored as missing, not as zero. This call only stores data here: nothing is sent to an ad platform.
Request
| Parameter | In | Needed | What it is |
|---|---|---|---|
Idempotency-Key | header | no | Your own unique value for this request, 8 to 191 characters. A repeat with the same key and the same body returns the first response with the header Idempotent-Replay: true instead of running the import again. |
Body
| Field | Type | Needed | What it is |
|---|---|---|---|
account | object | yes | The ad account the rows belong to. It is created on the first import and found by external_id after that. |
account. | string | yes | Your id of the ad account. The same id is the same account. |
account. | string | no | The name shown in the app. The default is the external_id. |
account. | string | yes | ISO 4217 code of the account, three letters. One currency for each account: use another external_id for results in another currency. |
account. | string | no | The time zone the account reports in (IANA name). |
account. | string | no | How the ad platform credits conversions for this account, in its own words. Kept so the numbers can be read correctly. |
rows | array of object | yes | The result rows, 1 to 2000 in one request. |
rows[]. | string | no | The ad platform's id of the campaign. A row that names an ad set or an ad must name its campaign, by id or by name. |
rows[]. | string | no | Name of the campaign. |
rows[]. | string | no | The ad platform's id of the ad set. |
rows[]. | string | no | Name of the ad set. |
rows[]. | string | no | The ad platform's id of the ad. |
rows[]. | string | no | Name of the ad. |
rows[]. | string (date) | yes | First day of the reporting period (YYYY-MM-DD). |
rows[]. | string (date) | no | Last day of the reporting period (YYYY-MM-DD). The default is date_start: one day. |
rows[]. | string | no | Currency of the row. The default is the account currency, and it must equal it. |
rows[]. | number | no | Amount spent in major units (333.33). Not negative. |
rows[]. | integer | no | Amount spent in minor units (33333), instead of spend. When both are sent, this one is used. |
rows[]. | integer | no | Times the ad was shown. |
rows[]. | integer | no | People who saw it. |
rows[]. | integer | no | All clicks. |
rows[]. | integer | no | Clicks on the link only. Kept apart from all clicks. |
rows[]. | integer | no | Leads as the ad platform reports them. Never added to the leads matched here. |
rows[]. | integer | no | Conversions as the ad platform reports them. |
rows[]. | number | no | Value of those conversions as the ad platform reports it, in major units. |
rows[]. | integer | no | The same value in minor units, instead of platform_conversion_value. |
rows[]. | string | no | How the ad platform credited conversions in this row, when it differs from the account. |
rows[]. | string | no | Objective of the campaign, in the words of the ad platform. |
rows[]. | string | no | Delivery status, in the words of the ad platform. |
rows[]. | string | no | The utm_campaign the ads carry. Used to suggest which campaign here the results belong to. |
rows[]. | string | no | Headline of the ad. |
rows[]. | string | no | Text of the ad. |
rows[]. | string | no | Call to action of the ad. |
rows[]. | string | no | The address the ad sends people to. |
curl -X POST https://heymysocial.com/api/v1/ads/import \
-H "Authorization: Bearer $HMS_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"account": {
"external_id": "1234567890",
"name": "Nordlys Solar ads",
"currency": "DKK",
"timezone": "Europe/Copenhagen",
"attribution_setting": "7d_click_1d_view"
},
"rows": [
{
"campaign_external_id": "c-201",
"campaign_name": "Spring roof check",
"adset_external_id": "s-11",
"adset_name": "Homeowners 35-60",
"ad_external_id": "a-501",
"ad_name": "Savings image",
"date_start": "2026-11-23",
"date_stop": "2026-11-23",
"spend": 333.33,
"impressions": 5500,
"reach": 4100,
"clicks": 88,
"link_clicks": 53,
"platform_leads": 7,
"objective": "leads",
"status": "active",
"utm_campaign": "spring-roof"
},
{
"campaign_external_id": "c-201",
"adset_external_id": "s-11",
"ad_external_id": "a-501",
"date_start": "2026-11-24",
"spend_minor": 28750,
"impressions": 4720,
"clicks": 61,
"link_clicks": 40,
"platform_leads": 4
},
{
"campaign_external_id": "c-201",
"date_start": "24/11/2026",
"spend": 10
}
]
}'
Responses
200 The import ran. Rows that could not be stored are listed in errors with their index.
| Field | Type | What it is |
|---|---|---|
batch_id | string | Id of this import. It is listed with the imports on the Paid screen. |
ad_account_id | string | Id of the ad account here. |
currency | string | The currency the account is stored in. |
rows_total | integer | Rows in the request. |
rows_stored | integer | Rows that are stored now: created, updated or unchanged. |
rows_failed | integer | Rows that were not stored. Each is in errors. |
summary | object | The rows counted by what happened to them. |
summary. | integer | New sets of numbers. |
summary. | integer | Same entity and dates as before, with new numbers. |
summary. | integer | Already stored with the same numbers. |
summary. | integer | Earlier rows removed because a new row overlaps their dates. |
summary. | integer | Rows left out without being an error. |
errors | array of object | One entry for each row that was not stored. At most 200 are listed. |
errors[]. | integer | Position of the row in rows, starting at 0. |
errors[]. | string | Why the row was not stored. |
{
"batch_id": "01m88q4x3yn5dkax2k37nwn3q1",
"ad_account_id": "01m88q4x3wtwrwgn6vxet2n5zx",
"currency": "DKK",
"rows_total": 3,
"rows_stored": 2,
"rows_failed": 1,
"summary": {
"created": 2,
"updated": 0,
"unchanged": 0,
"replaced": 0,
"skipped": 0
},
"errors": [
{
"index": 2,
"message": "The reporting dates are missing or not dates (use 2026-11-24)."
}
]
}
401 unauthenticated: the API key is missing, mistyped, revoked or expired.
The error shape and every code
403 access_denied: the key lacks the scope ads:write.
The error shape and every code
409 duplicate: the Idempotency-Key was already used with a different request, or the first request with it is still running (then retryable is true).
The error shape and every code
422 validation_failed: the request as a whole cannot be read. The account has no external_id or no currency, rows is missing, empty or longer than 2000, or the currency differs from the one the account is stored in. Nothing was stored.
The error shape and every code