Skip to content

Create a gift link (API key)

POST
/v1/gift-links
curl --request POST \
--url https://your-tenant-host/v1/gift-links \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-edgekit-site-id: site_example' \
--data '{ "content": { "payload": "{\"article_id\":\"a-1\",\"section\":\"news\",\"paywall_level\":\"2\"}", "signature": "example" }, "context": { "additionalProperty": "example" }, "userId": "0199a4c2-7b1e-7c3d-9a4f-2e8b5d6c1a90", "expiresInDays": 1 }'

Evaluates the tenant’s gift-link create feature for the gifter and this page, charging its meters, and mints a token only on allow. A deny is 200 with the create feature’s decision. 401 on the browser route when no user is signed in, 404 when gifting is not configured, 422 when the page carries no value for the tenant’s key fact. Same rate limits as POST /decide. Not idempotent: every call charges the quota and mints a new link — retry only a request that got no answer.

x-edgekit-site-id
required

The site this request is for, within this tenant. Every official EdgeKit SDK sets it from the client you configured; set it yourself only when calling this API directly.

string
>= 1 characters <= 128 characters

Example

site_example

The site this request is for, within this tenant. Every official EdgeKit SDK sets it from the client you configured; set it yourself only when calling this API directly.

Media typeapplication/json
object
content
object
payload
required

The content descriptor, serialised. Signed as these exact bytes — there is no canonicalisation step, because a canonicalising scheme is a second parser that has to agree with the first.

string
>= 1 characters

Example

{"article_id":"a-1","section":"news","paywall_level":"2"}
signature
required

Base64url HMAC-SHA256 of payload under this site’s content key.

string
>= 1 characters
context

Unverified, as on decide. The link’s content_key may bind to a context.* fact; the view rule, reading the viewed page, is the gate.

object
key
additional properties
userId

The gifter. Keyed route only, refused (403) on /edgekit/v1/gift-links. Absent on the keyed route mints an internal gift link.

string format: uuid
>= 1 characters

Example

0199a4c2-7b1e-7c3d-9a4f-2e8b5d6c1a90
expiresInDays

A shorter life than the tenant’s TTL, never longer. Keyed route only, refused (403) on the browser route.

integer
>= 1

Created, or denied by the create feature.

Media typeapplication/json
object
status
required

created carries token and expiresAt; denied is the create feature answering no. Open: treat a member not listed as not created.

string
token

The signed gift-link token, for the ?_gt parameter. created only.

string
expiresAt

When the token stops opening anything. created only.

string format: date-time
decision
required
object
outcome
required

The id the site switches on.

string | null
value

The winning outcome’s own named fields, flattened to plain JSON — never a stringified blob. Absent for a plain outcome, where the id is the whole answer. A ref field resolves to a curated catalog object (never a bare id) carrying exactly the keys its select named.

type

Present iff the matched outcome declared one. allow/deny is an access verdict; redirect names a destination (see GET /decide/forward); data is neither. Open: accept a member not listed.

string
reason
required
string
reasonDetail
string
meters

The meter reads this feature’s rules made, keyed by meter name, as read — before this request’s own ticks. allowance - count is what was left going in. Absent when no rule read a meter. Under an outcome preview pin the pinned feature still carries the reads its unpinned rules make for this request, and nothing counts.

object
key
additional properties
object
count
required
integer
allowance
required
integer
checkoutPageUrls

The checkout page URL of each offer_token field whose outcome sells on a checkout page, keyed by the field name. The URL carries the token, so link to it as it is. Absent when no field names a checkout page.

object
key
additional properties
string
experience

What the site shows for this outcome, drawn by the browser client beside the decision. Absent when the site has none for it.

object
url
required

The module, root-relative and immutable: resolve it against the page’s own origin.

string
contract
required

The module contract it was written against.

integer
display
required
object
kind
required

Open: accept a member not listed. Known: modal, banner, slide-in, inline.

string
edge

A banner’s edge.

string
corner

A slide-in’s corner.

string
width

An inline’s width; column when absent.

string
dismiss

How long a closed modal, banner or slide-in stays closed: none (it cannot be closed), page (until the next page; also when absent), session or forever.

string
trigger
required
object
kind
required

Open: accept a member not listed. Known: immediate, delay, scroll, exit-intent.

string
seconds

A delay’s seconds, 1–600.

integer
percent

A scroll’s percent of the page, 1–100.

integer
brand
required

The site’s brand, or null when it has none.

object
logo
required
string | null
colors
required
object
key
additional properties
string
font
required
string | null

Example

{
"status": "created",
"expiresAt": "2026-10-10T12:00:00.000Z",
"decision": {
"type": "allow",
"experience": {
"url": "/edgekit/x/0000000000000000000000000000000000000000000000000000000000000000.js",
"display": {
"kind": "modal",
"edge": "top",
"corner": "bottom-right",
"width": "column",
"dismiss": "none"
},
"trigger": {
"kind": "immediate"
}
}
}
}

Invalid request.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details

Example

{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key."
}
}

Missing or invalid credential.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details

Example

{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key."
}
}

Not allowed.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details

Example

{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key."
}
}

Resource not found.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details

Example

{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key."
}
}

Request body too large.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details

Example

{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key."
}
}

Request validation failed.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details

Example

{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key."
}
}

Too many requests. Retry-After says when to retry.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details

Example

{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key."
}
}

Unexpected error.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details

Example

{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key."
}
}

With Retry-After, briefly unavailable; without it, not configured.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details

Example

{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key."
}
}

edgekit.ai