Skip to the page

REST API

Resources

Resources: 15 endpoints of the REST API.

GET/resource-types

List resource types

Resource types of this environment, newest first. Archived ones are left out unless status=archived.

Secret key scope (any of): links:read, links:write

Parameters

FieldTypeDescription
limit (query)integer

Items per page (1–100).

cursor (query)string

next_cursor of the previous page; omit for the first page. A cursor only works with the sort order it was issued for.

status (query)"active" | "archived"

Only types with this status. Archived types are left out by default.

Responses

200 A page of resource types.

FieldTypeDescription
datarequiredobject[]
data[].idrequiredstring
data[].keyrequiredstring
data[].namerequiredstring
data[].statusrequired"active" | "archived"
data[].created_atrequiredstring (date-time)
data[].updated_atrequiredstring (date-time)
next_cursorrequiredstring | null

Pass as cursor to get the next page; null on the last page.

Example

Bash
POST/resource-types

Create a resource type

Defines something you share through URL templates, for example challenge. The key is used in payloads and cannot be changed. An environment can have 20 resource types.

Secret key scope (any of): links:write

Request body

FieldTypeDescription
keyrequiredstring

Stable machine name (for example challenge); used in payloads and cannot be changed.

namerequiredstring

Responses

201 The new resource type.

FieldTypeDescription
idrequiredstring
keyrequiredstring
namerequiredstring
statusrequired"active" | "archived"
created_atrequiredstring (date-time)
updated_atrequiredstring (date-time)

Example

Bash
GET/resource-types/{type}

Get a resource type

One resource type, archived ones included.

Secret key scope (any of): links:read, links:write

Parameters

FieldTypeDescription
type (path)requiredstring

The ID of the resource type.

Responses

200 The resource type.

FieldTypeDescription
idrequiredstring
keyrequiredstring
namerequiredstring
statusrequired"active" | "archived"
created_atrequiredstring (date-time)
updated_atrequiredstring (date-time)

Example

Bash
PATCH/resource-types/{type}

Update a resource type

Renames a resource type or archives it (status: archived). Templates of an archived type stop resolving; their patterns stay reserved. The key cannot change.

Secret key scope (any of): links:write

Parameters

FieldTypeDescription
type (path)requiredstring

The ID of the resource type.

Request body

FieldTypeDescription
namestring
status"active" | "archived"

Archive a type to stop its templates resolving; its key stays taken.

Responses

200 The updated resource type.

FieldTypeDescription
idrequiredstring
keyrequiredstring
namerequiredstring
statusrequired"active" | "archived"
created_atrequiredstring (date-time)
updated_atrequiredstring (date-time)

Example

Bash
GET/resource-types/{type}/metadata-api

Get the metadata API of a resource type

The endpoint, field mapping and cache settings. The credential is never returned: auth.secret_set says whether one is stored and auth.secret_hint shows its last characters.

Secret key scope (any of): links:read, links:write

Parameters

FieldTypeDescription
type (path)requiredstring

The ID of the resource type.

Responses

200 The configuration.

FieldTypeDescription
idrequiredstring
resource_type_idrequiredstring
statusrequired"active" | "disabled"
url_templaterequiredstring
authrequiredobject
auth.typerequired"none" | "bearer" | "api_key_header"
auth.header_namerequiredstring | null
auth.secret_setrequiredboolean
auth.secret_hintrequiredstring | null

The last characters of the stored credential, to tell keys apart.

headersrequiredobject
timeout_msrequiredinteger
ttl_secondsrequiredinteger
negative_ttl_secondsrequiredinteger
stale_if_error_secondsrequiredinteger
max_concurrencyrequiredinteger
max_requests_per_minuterequiredinteger
field_mappingrequiredobject
field_mapping.titlestring
field_mapping.descriptionstring
field_mapping.image_urlstring
field_mapping.canonical_urlstring
field_mapping.deep_link_pathstring
field_mapping.web_fallback_urlstring
field_mapping.resource_statusstring
field_defaultsrequiredobject
field_defaults.titlestring
field_defaults.descriptionstring
field_defaults.image_urlstring
field_defaults.canonical_urlstring
field_defaults.deep_link_pathstring
field_defaults.web_fallback_urlstring
required_fieldsrequired"title" | "description" | "image_url" | "canonical_url" | "deep_link_path" | "web_fallback_url"[]
status_valuesrequiredobject
status_values.publishedstring[]
status_values.unpublishedstring[]
status_values.deletedstring[]
allowed_image_hostsrequiredstring[]
created_atrequiredstring (date-time)
updated_atrequiredstring (date-time)

Example

Bash
PUT/resource-types/{type}/metadata-api

Set the metadata API of a resource type

Creates or replaces the configuration (one per resource type). url_template is an https URL on a public host name with {type} and {id} in the path or query. Previews of this type then show each item’s own title, description and image from your API: it is called only for link-preview bots, its answers are cached, and a failing API never slows a visitor down. Omit auth.secret to keep the stored credential.

Secret key scope (any of): links:write

Parameters

FieldTypeDescription
type (path)requiredstring

The ID of the resource type.

Request body

FieldTypeDescription
status"active" | "disabled"

disabled keeps the configuration but previews use the generic card.

url_templaterequiredstring

HTTPS URL of your metadata endpoint, with {type} and {id} in the path or query, for example https://api.example.com/link-metadata/{type}/{id}.

authobject
headersobject

Extra, non-secret request headers.

timeout_msinteger
ttl_secondsinteger

How long an answer is used without asking again.

negative_ttl_secondsinteger

How long a 404 or 410 ("no such item") is remembered.

stale_if_error_secondsinteger

How long past its TTL an answer may still be shown when your API fails.

max_concurrencyinteger
max_requests_per_minuteinteger
field_mappingrequiredobject
field_mapping.titlestring
field_mapping.descriptionstring
field_mapping.image_urlstring
field_mapping.canonical_urlstring
field_mapping.deep_link_pathstring
field_mapping.web_fallback_urlstring
field_mapping.resource_statusstring
field_defaultsobject
field_defaults.titlestring
field_defaults.descriptionstring
field_defaults.image_urlstring
field_defaults.canonical_urlstring
field_defaults.deep_link_pathstring
field_defaults.web_fallback_urlstring
required_fields"title" | "description" | "image_url" | "canonical_url" | "deep_link_path" | "web_fallback_url"[]
status_valuesobject
status_values.publishedstring[]
status_values.unpublishedstring[]
status_values.deletedstring[]
allowed_image_hostsstring[]

Hosts an image may come from. An image on any other host is left out of the card.

Responses

200 The saved configuration.

FieldTypeDescription
idrequiredstring
resource_type_idrequiredstring
statusrequired"active" | "disabled"
url_templaterequiredstring
authrequiredobject
auth.typerequired"none" | "bearer" | "api_key_header"
auth.header_namerequiredstring | null
auth.secret_setrequiredboolean
auth.secret_hintrequiredstring | null

The last characters of the stored credential, to tell keys apart.

headersrequiredobject
timeout_msrequiredinteger
ttl_secondsrequiredinteger
negative_ttl_secondsrequiredinteger
stale_if_error_secondsrequiredinteger
max_concurrencyrequiredinteger
max_requests_per_minuterequiredinteger
field_mappingrequiredobject
field_mapping.titlestring
field_mapping.descriptionstring
field_mapping.image_urlstring
field_mapping.canonical_urlstring
field_mapping.deep_link_pathstring
field_mapping.web_fallback_urlstring
field_mapping.resource_statusstring
field_defaultsrequiredobject
field_defaults.titlestring
field_defaults.descriptionstring
field_defaults.image_urlstring
field_defaults.canonical_urlstring
field_defaults.deep_link_pathstring
field_defaults.web_fallback_urlstring
required_fieldsrequired"title" | "description" | "image_url" | "canonical_url" | "deep_link_path" | "web_fallback_url"[]
status_valuesrequiredobject
status_values.publishedstring[]
status_values.unpublishedstring[]
status_values.deletedstring[]
allowed_image_hostsrequiredstring[]
created_atrequiredstring (date-time)
updated_atrequiredstring (date-time)

Example

Bash
POST/resource-types/{type}/metadata-api/test

Test the metadata API with a real item

Calls your API for the item id with the saved configuration and reports what came back: the HTTP status, the time it took, the metadata that was read, and why anything was left out. Nothing is cached or counted.

Secret key scope (any of): links:write

Parameters

FieldTypeDescription
type (path)requiredstring

The ID of the resource type.

Request body

FieldTypeDescription
idrequiredstring

The id of a real item to ask your API for.

Responses

200 The result of the call.

FieldTypeDescription
outcomerequired"ok" | "missing" | "invalid" | "error" | "skipped"

ok: usable metadata; missing: your API answered 404/410; invalid: an answer that cannot be used; error: no usable answer (timeout, 5xx, authentication …); skipped: no call was made.

reasonrequiredstring | null

A short stable code for invalid and error.

statusrequiredinteger | null

The HTTP status your API answered.

latency_msrequiredinteger | null
request_urlrequiredstring | null

The URL that was called, with the sample id filled in. Never includes a credential.

metadatarequiredobject | null
warningsrequiredobject[]
warnings[].fieldrequiredstring
warnings[].coderequiredstring
warnings[].detailrequiredstring
issuesrequiredobject[]
issues[].fieldrequiredstring
issues[].coderequiredstring
issues[].detailrequiredstring

Example

Bash
POST/resources/invalidate

Invalidate remembered metadata

Call it when items changed or were deleted in your system. Beck Link forgets what it remembered about them (up to 1,000 ids per call), so the next link preview asks your metadata API again. Link previews that chat apps and social networks already stored are refreshed by those services, not by this call.

Secret key scope (any of): links:write

Request body

FieldTypeDescription
resource_typerequiredstring

The key of the resource type, for example challenge.

idsrequiredstring[]

The ids of the changed items, at most 1000.

Responses

200 How many were removed.

FieldTypeDescription
resource_typerequiredstring
requestedrequiredinteger

How many ids were sent.

removedrequiredinteger

How many of them had a remembered answer that is now gone.

Example

Bash
POST/resources/preview

Preview a shared URL

Resolves a URL such as https://shop.becklinks.com/c/4521 to its template and item, asks your metadata API for it right now, and returns the card a link-preview bot would see together with the state of the shared cache.

Secret key scope (any of): links:read, links:write

Request body

FieldTypeDescription
pathrequiredstring

A shared URL or path such as /c/4521; the query is ignored.

Responses

200 The preview.

FieldTypeDescription
resultrequired"match" | "invalid_id" | "no_template"
resourcerequiredobject | null
metadata_apirequired"active" | "disabled" | "none"
fetchrequiredobject | null
cacherequiredobject
cache.staterequired"none" | "fresh" | "stale" | "missing"
cache.fetched_atrequiredstring (date-time) | null
cache.expires_atrequiredstring (date-time) | null
cardrequiredobject
card.kindrequired"item" | "unavailable" | "generic"

item: the item's own card; unavailable: deleted, unpublished or unknown; generic: the app's plain card.

card.titlerequiredstring | null
card.descriptionrequiredstring | null
card.image_urlrequiredstring | null
card.large_imagerequiredboolean
detailrequiredstring

Example

Bash
GET/resources/stats

Get the analytics of resource links

Per resource type: non-bot clicks, the most clicked items, how link previews were answered (cache hit rate) and how your metadata API behaved (calls, errors, latency) over the last 7 or 30 project-local days. Item clicks are read from the raw click log; API figures are flushed every few seconds, so the newest minutes may be missing.

Secret key scope (any of): analytics:read

Parameters

FieldTypeDescription
range (query)"7d" | "30d"

The last 7 or 30 project-local days, today included. Default 7d.

Responses

200 The analytics.

FieldTypeDescription
rangerequired"7d" | "30d"
fromrequiredstring (date)

First day of the range (project-local).

torequiredstring (date)

Last day of the range, today (project-local).

timezonerequiredstring
typesrequiredobject[]
types[].resource_typerequiredstring

The key of the resource type.

types[].clicksrequiredinteger

Non-bot clicks on items of this type.

types[].top_itemsrequiredobject[]

The 10 most clicked items.

types[].top_items[].idrequiredstring

The item id as it appeared in the URL.

types[].top_items[].clicksrequiredinteger

Non-bot clicks on this item.

types[].previewsrequiredobject
types[].previews.servedrequiredinteger

Link previews built for bots and social apps.

types[].previews.from_memoryrequiredinteger

Answered from the memory of a redirect process.

types[].previews.from_databaserequiredinteger

Answered from the shared cache.

types[].previews.from_negative_cacherequiredinteger

Answered from a remembered "item not found".

types[].previews.stalerequiredinteger

Answered with an expired copy while the API was refreshed or failing.

types[].previews.fallbackrequiredinteger

Answered with the generic card (no item data available).

types[].previews.cache_hit_raterequirednumber | null

Share of previews that did not call your API; null without previews.

types[].metadata_apirequiredobject
types[].metadata_api.callsrequiredinteger

Calls to your metadata API.

types[].metadata_api.okrequiredinteger

Calls that returned an item.

types[].metadata_api.missingrequiredinteger

Calls that said the item does not exist.

types[].metadata_api.errorsrequiredinteger

Calls that failed (HTTP error or network).

types[].metadata_api.timeoutsrequiredinteger

Calls that ran out of time.

types[].metadata_api.invalidrequiredinteger

Calls whose answer could not be used.

types[].metadata_api.breaker_openrequiredinteger

Calls skipped because the circuit breaker was open.

types[].metadata_api.throttledrequiredinteger

Calls skipped by the concurrency or per-minute limit.

types[].metadata_api.error_raterequirednumber | null
types[].metadata_api.avg_latency_msrequiredinteger | null
types[].metadata_api.p95_bucketrequired"lt_100" | "lt_300" | "lt_1000" | "ge_1000" | null

The latency bucket that holds the 95th percentile (a rough value by design).

Example

Bash
GET/url-templates

List URL templates

Templates of this environment, newest first. Filter by resource_type_id and status; archived ones are left out unless status=archived.

Secret key scope (any of): links:read, links:write

Parameters

FieldTypeDescription
limit (query)integer

Items per page (1–100).

cursor (query)string

next_cursor of the previous page; omit for the first page. A cursor only works with the sort order it was issued for.

resource_type_id (query)string

Only templates of this type.

status (query)"active" | "disabled" | "archived"

Only templates with this status. Archived templates are left out by default.

Responses

200 A page of templates.

FieldTypeDescription
datarequiredobject[]
data[].idrequiredstring
data[].resource_type_idrequiredstring
data[].resource_typerequiredstring

Key of the resource type.

data[].path_patternrequiredstring
data[].url_examplerequiredstring

The pattern on the environment’s shared host, for example https://shop.becklinks.com/c/{id}.

data[].id_formatrequiredobject

How the id in the URL is validated: a preset (numeric, alnum, uuid, ulid, base64url) or an explicit character set with length bounds.

data[].deep_link_pathrequiredstring
data[].datarequiredobject
data[].redirectsrequiredobject
data[].redirects.iosrequiredstring | null
data[].redirects.androidrequiredstring | null
data[].redirects.webrequiredstring | null
data[].redirects.desktoprequiredstring | null
data[].redirects.fallbackrequiredstring | null
data[].allow_param_passthroughrequiredboolean
data[].statusrequired"active" | "disabled" | "archived"
data[].created_atrequiredstring (date-time)
data[].updated_atrequiredstring (date-time)
next_cursorrequiredstring | null

Pass as cursor to get the next page; null on the last page.

Example

Bash
POST/url-templates

Create a URL template

Shares path_pattern (for example /c/{id}) for a resource type on the environment’s link host. id_format says what an id looks like; deep_link_path, data and redirects may contain {id} and {type}. The pattern cannot change later. A type can have 5 templates. A destination URL that looks suspicious is saved and listed in warnings; one that is listed as dangerous is refused with 422 url_blocked.

Secret key scope (any of): links:write

Request body

FieldTypeDescription
resource_type_idrequiredstring

The resource type this pattern shares.

path_patternrequiredstring

The URL pattern, for example /c/{id}. It cannot be changed later.

id_formatrequiredobject

How the id in the URL is validated: a preset (numeric, alnum, uuid, ulid, base64url) or an explicit character set with length bounds.

deep_link_pathrequiredstring

In-app route handed to the SDK, for example /challenge/{id}. {id} is percent-encoded.

dataobject

Custom JSON delivered with the link; {id} and {type} work in string values.

redirectsobject | null

Per-platform destinations. ios and android take https or a custom app scheme, the rest https only; {id} and {type} fill the path, query or fragment.

allow_param_passthroughboolean

Pass query parameters added to the short URL on to the app payload (LNK-005).

Responses

201 The new template.

FieldTypeDescription
idrequiredstring
resource_type_idrequiredstring
resource_typerequiredstring

Key of the resource type.

path_patternrequiredstring
url_examplerequiredstring

The pattern on the environment’s shared host, for example https://shop.becklinks.com/c/{id}.

id_formatrequiredobject

How the id in the URL is validated: a preset (numeric, alnum, uuid, ulid, base64url) or an explicit character set with length bounds.

deep_link_pathrequiredstring
datarequiredobject
redirectsrequiredobject
redirects.iosrequiredstring | null
redirects.androidrequiredstring | null
redirects.webrequiredstring | null
redirects.desktoprequiredstring | null
redirects.fallbackrequiredstring | null
allow_param_passthroughrequiredboolean
statusrequired"active" | "disabled" | "archived"
created_atrequiredstring (date-time)
updated_atrequiredstring (date-time)
warningsrequiredobject[]
warnings[].coderequired"destination_suspicious"
warnings[].pointerrequiredstring

JSON Pointer to the field the warning is about.

warnings[].detailrequiredstring
warnings[].reasonsrequiredstring[]

Stable reason codes of the URL check.

Example

Bash
POST/url-templates/test

Test a URL against the templates

Shows which template and id a URL or path resolves to and what it would render. Nothing is counted or stored.

Secret key scope (any of): links:read, links:write

Request body

FieldTypeDescription
pathrequiredstring

A URL path such as /c/4521, or a full URL; the query is ignored.

Responses

200 The outcome.

FieldTypeDescription
resultrequired"match" | "invalid_id" | "no_template"
template_idrequiredstring | null
resource_typerequiredstring | null
idrequiredstring | null

The id taken from the URL, decoded.

renderedrequiredobject | null
detailrequiredstring

Why the path resolved, or did not, in a sentence.

Example

Bash
GET/url-templates/{template}

Get a URL template

One template, archived ones included.

Secret key scope (any of): links:read, links:write

Parameters

FieldTypeDescription
template (path)requiredstring

The ID of the URL template.

Responses

200 The template.

FieldTypeDescription
idrequiredstring
resource_type_idrequiredstring
resource_typerequiredstring

Key of the resource type.

path_patternrequiredstring
url_examplerequiredstring

The pattern on the environment’s shared host, for example https://shop.becklinks.com/c/{id}.

id_formatrequiredobject

How the id in the URL is validated: a preset (numeric, alnum, uuid, ulid, base64url) or an explicit character set with length bounds.

deep_link_pathrequiredstring
datarequiredobject
redirectsrequiredobject
redirects.iosrequiredstring | null
redirects.androidrequiredstring | null
redirects.webrequiredstring | null
redirects.desktoprequiredstring | null
redirects.fallbackrequiredstring | null
allow_param_passthroughrequiredboolean
statusrequired"active" | "disabled" | "archived"
created_atrequiredstring (date-time)
updated_atrequiredstring (date-time)

Example

Bash
PATCH/url-templates/{template}

Update a URL template

Changes the fields sent. The pattern and the resource type stay as they are, because links already shared depend on them. status: disabled keeps the pattern and answers with a status page; archived frees the pattern. A destination URL that looks suspicious is saved and listed in warnings; one that is listed as dangerous is refused with 422 url_blocked.

Secret key scope (any of): links:write

Parameters

FieldTypeDescription
template (path)requiredstring

The ID of the URL template.

Request body

FieldTypeDescription
id_formatobject

How the id in the URL is validated: a preset (numeric, alnum, uuid, ulid, base64url) or an explicit character set with length bounds.

deep_link_pathstring

In-app route handed to the SDK, for example /challenge/{id}. {id} is percent-encoded.

dataobject

Custom JSON delivered with the link; {id} and {type} work in string values.

redirectsobject | null

Per-platform destinations. ios and android take https or a custom app scheme, the rest https only; {id} and {type} fill the path, query or fragment.

allow_param_passthroughboolean

Pass query parameters added to the short URL on to the app payload (LNK-005).

status"active" | "disabled" | "archived"

disabled keeps the pattern and answers with a status page; archived frees the pattern.

Responses

200 The updated template.

FieldTypeDescription
idrequiredstring
resource_type_idrequiredstring
resource_typerequiredstring

Key of the resource type.

path_patternrequiredstring
url_examplerequiredstring

The pattern on the environment’s shared host, for example https://shop.becklinks.com/c/{id}.

id_formatrequiredobject

How the id in the URL is validated: a preset (numeric, alnum, uuid, ulid, base64url) or an explicit character set with length bounds.

deep_link_pathrequiredstring
datarequiredobject
redirectsrequiredobject
redirects.iosrequiredstring | null
redirects.androidrequiredstring | null
redirects.webrequiredstring | null
redirects.desktoprequiredstring | null
redirects.fallbackrequiredstring | null
allow_param_passthroughrequiredboolean
statusrequired"active" | "disabled" | "archived"
created_atrequiredstring (date-time)
updated_atrequiredstring (date-time)
warningsrequiredobject[]
warnings[].coderequired"destination_suspicious"
warnings[].pointerrequiredstring

JSON Pointer to the field the warning is about.

warnings[].detailrequiredstring
warnings[].reasonsrequiredstring[]

Stable reason codes of the URL check.

Example

Bash