Skip to content
Denne side findes på dansk. Læs på dansk
HeyMySocial

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

ParameterInNeededWhat it is
Idempotency-KeyheadernoYour 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

FieldTypeNeededWhat it is
accountobjectyes The ad account the rows belong to. It is created on the first import and found by external_id after that.
account.external_idstringyes Your id of the ad account. The same id is the same account.
account.namestringno The name shown in the app. The default is the external_id.
account.currencystringyes ISO 4217 code of the account, three letters. One currency for each account: use another external_id for results in another currency.
account.timezonestringno The time zone the account reports in (IANA name).
account.attribution_settingstringno How the ad platform credits conversions for this account, in its own words. Kept so the numbers can be read correctly.
rowsarray of objectyes The result rows, 1 to 2000 in one request.
rows[].campaign_external_idstringno 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[].campaign_namestringno Name of the campaign.
rows[].adset_external_idstringno The ad platform's id of the ad set.
rows[].adset_namestringno Name of the ad set.
rows[].ad_external_idstringno The ad platform's id of the ad.
rows[].ad_namestringno Name of the ad.
rows[].date_startstring (date)yes First day of the reporting period (YYYY-MM-DD).
rows[].date_stopstring (date)no Last day of the reporting period (YYYY-MM-DD). The default is date_start: one day.
rows[].currencystringno Currency of the row. The default is the account currency, and it must equal it.
rows[].spendnumberno Amount spent in major units (333.33). Not negative.
rows[].spend_minorintegerno Amount spent in minor units (33333), instead of spend. When both are sent, this one is used.
rows[].impressionsintegerno Times the ad was shown.
rows[].reachintegerno People who saw it.
rows[].clicksintegerno All clicks.
rows[].link_clicksintegerno Clicks on the link only. Kept apart from all clicks.
rows[].platform_leadsintegerno Leads as the ad platform reports them. Never added to the leads matched here.
rows[].platform_conversionsintegerno Conversions as the ad platform reports them.
rows[].platform_conversion_valuenumberno Value of those conversions as the ad platform reports it, in major units.
rows[].platform_conversion_value_minorintegerno The same value in minor units, instead of platform_conversion_value.
rows[].attribution_settingstringno How the ad platform credited conversions in this row, when it differs from the account.
rows[].objectivestringno Objective of the campaign, in the words of the ad platform.
rows[].statusstringno Delivery status, in the words of the ad platform.
rows[].utm_campaignstringno The utm_campaign the ads carry. Used to suggest which campaign here the results belong to.
rows[].creative_titlestringno Headline of the ad.
rows[].creative_bodystringno Text of the ad.
rows[].creative_ctastringno Call to action of the ad.
rows[].creative_linkstringno 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.

FieldTypeWhat it is
batch_idstringId of this import. It is listed with the imports on the Paid screen.
ad_account_idstringId of the ad account here.
currencystringThe currency the account is stored in.
rows_totalintegerRows in the request.
rows_storedintegerRows that are stored now: created, updated or unchanged.
rows_failedintegerRows that were not stored. Each is in errors.
summaryobjectThe rows counted by what happened to them.
summary.createdintegerNew sets of numbers.
summary.updatedintegerSame entity and dates as before, with new numbers.
summary.unchangedintegerAlready stored with the same numbers.
summary.replacedintegerEarlier rows removed because a new row overlaps their dates.
summary.skippedintegerRows left out without being an error.
errorsarray of objectOne entry for each row that was not stored. At most 200 are listed.
errors[].indexintegerPosition of the row in rows, starting at 0.
errors[].messagestringWhy 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

429 rate_limited: too many requests with this key in one minute. Wait and send it again.

The error shape and every code