Links

Create a short link

Creates a short URL. Anonymous callers share rate limits with the web create form. Session cookie and API key are optional for basic create; higher capacity may require an API key when issued. Request body must include exactly one of url or longUrl (OpenAPI oneOf). Optional alias / customSlug: if both are sent they must match (case-insensitive); otherwise 409 FIELD_CONFLICT. User aliases are folded to lowercase before persistence. An OAuth access token is not an API key here: presenting one is 401 and does not fall through to anonymous create.

post/v1/links

Request

  • Base URL: https://xn--s7y.xn--3ds443g
  • URL: https://xn--s7y.xn--3ds443g/v1/links
  • Auth: one of:
    • none
    • HTTP bearer
    • API key in cookie duan_session

Headers

Idempotency-Keystring required
Example:550e8400-e29b-41d4-a716-446655440000

Client-generated key. Scope = authenticated user or API key, or anonymous client id (X-Duan-Client-Id / sealed anon cookie) — not IP-only. TTL=24h; same key+body replays; same key+different body → 409 IDEMPOTENCY_CONFLICT; concurrent same key → 409 IDEMPOTENCY_IN_PROGRESS + Retry-After. Concurrent reuse of the same key is safe; on IDEMPOTENCY_IN_PROGRESS wait Retry-After and retry with the same key.

X-Duan-Client-Idstring

Sealed anonymous_client_id (agents). Omit on first request — server mints and echoes the same header (+ Set-Cookie duan_anon) on the response that entered idempotency scope, including 409 and 503. Resend on subsequent anon calls. Not a credential.

X-Request-Idstring

Optional correlation id. The server echoes it back (X-Request-Id response header and request_id) only if it matches [A-Za-z0-9._-]{1,128}; any other value is ignored and a fresh id is returned.

Request body

OR

Example request

{
  "source": "agent"
}

Response

Idempotent replay of a prior successful create (see Idempotency-Replayed)

OR

Example response

{
  "short_url": "https://短.在线/a7x",
  "short_url_ascii": "https://xn--s7y.xn--3ds443g/a7x"
}

Changes

No recorded changes to this operation across all 1 revision of this API.