Skip to content

Create an embeddable ads connection session

POST /api/embed/ads-sessions

Returns a single-use URL to embed in an iframe: the end user logs in to Meta inside it and chooses which ad accounts to activate. The token in clear text is shown only once. On activation, Neike notifies by webhook (ads.connected) and the result is available through GET of the session. It requires that someone has accepted the Marketing terms: otherwise it answers 403 on creation, not inside the iframe. Requires the marketing:manage scope.

FieldTypeDescription
allowed_originsstring[]requiredOrigins allowed to embed the iframe. They feed the frame-ancestors of the CSP and the targetOrigin of the result postMessage. Up to 10. Example: ["https://app.tu-dominio.com"].
external_refstringoptionalBusiness id in the client’s system. It comes back unchanged in the webhook and in the result, to correlate the accounts with their tenant. Example: "tenant_8842".
ttl_minutesnumberoptionalValidity of the session in minutes. Default: 30.
providermetaoptionalAds provider. Today only meta; any other value answers 400 unsupported_provider. Default: "meta".
StatusDescriptionSchema
201—EmbedAdsSessionCreatedDto
400Invalid origins, ttl out of range or unsupported provider.—
403Nobody accepted the current version of the Marketing terms (error: marketing_terms_not_accepted).—
Terminal window
curl -X POST https://api.neike.dev/api/embed/ads-sessions \
-H "x-neike-api-key: whk_live_…" \
-H "Content-Type: application/json" \
-d '{
"allowed_origins": [
"https://app.tu-dominio.com"
]
}'
FieldTypeDescription
session_idstringrequiredExample: "nkes_9fQ2aB…".
tokenstringrequiredSession token. It is returned only once; only its SHA-256 is stored. Example: "nkst_…".
embed_urlstringrequiredURL ready to embed in the iframe. Example: "https://api.neike.dev/embed/ads?token=nkst_…".
iframe_snippetstringrequired<iframe> snippet ready to paste (sandbox included).
providermetarequiredExample: "meta".
allowed_originsstring[]required—
external_refstringoptional—
expires_atstring (date-time)required—
statuspendingrequiredExample: "pending".