KDPika Licensing Sign inStart free
API v1
Show all languages
Browse documentation

Choose a page in the navigation drawer.

KDPika Licensing · API v1 Intermediate

Restore a license

Restore an eligible license without reviving old tokens.

On this page
Updated 2026-10-17 UTCDownload Markdown

Restore an eligible license without reviving old tokens.

What you will learn

  • Send this exact operation with its required credentials and fields.
  • Interpret success, refusal, side effects and retry risks.

Prerequisites

Method and path

POST /api/v1/licenses/{license}/restore

When to use it

Return an eligible SUSPENDED or PENDING license to ACTIVE after the underlying issue is resolved. An already ACTIVE license can also accept this operation. Revoked/cancelled licenses cannot be restored.

Authentication and environment

Use Authorization: Bearer YOUR_DEVELOPER_API_KEY with scope licenses:write. The key fixes the organization/product/environment; X-Environment cannot override it.

Request headers

HeaderRequiredDescriptionExample
AcceptrecommendedJSON responsesapplication/json
Content-Typefor JSON bodyUse the documented JSON objectapplication/json
AuthorizationyesScoped backend-only developer keyBearer YOUR_DEVELOPER_API_KEY

Path and query parameters

ParameterTypeRequiredDescriptionExample
licensestringyesOpaque license identifier. Scoped lookup returns 404; no UUID/length contract.YOUR_LICENSE_ID

No pagination, filtering, sorting or list query parameters are implemented. Use JSON rather than relying on alternate form/query parsing.

Request body

FieldTypeRequiredConstraints/defaultDescriptionExample
reasonstringnomaxLength=190Optional trimmed reason; invalid length becomes null."Customer support request"

Full request JSON

jsonjson
{
  "reason": "Customer support request"
}

The schemas describe supported recommended input types. Current PHP parsing trims/casts strings and may ignore unknown fields; it is not strict JSON-schema validation. Invalid optional descriptive fields can become empty/null. Conventions describes malformed JSON and alternate parsing.

Success response

HTTP 200. The following is a real isolated Sandbox capture; secret values are replaced with explicit placeholders.

jsonjson
{
  "success": true,
  "license": {
    "id": "lic_578581bd80c2a672da30fc29",
    "status": "active"
  },
  "request_id": "req_0dd8d2e77cf580ba8b5d491f"
}

Response fields

FieldTypeRequiredConstraintsDescriptionExample
successbooleanyesconst=trueThe operation succeeded.true
licenseobjectyesSee descriptionState result; old revoked tokens do not revive.Nested object/array shown in full JSON
license.idstringyesSee descriptionLicense identifier."lic_578581bd80c2a672da30fc29"
license.statusstringyesenum=["active", "suspended", "revoked"]Resulting state."active"
request_idstringyespattern="^req_[a-f0-9]{24}$"Request correlation ID. Replay bodies can retain an earlier ID."req_0dd8d2e77cf580ba8b5d491f"

Response headers

X-Request-ID identifies the current request. Successful limited calls include X-RateLimit-Remaining and X-RateLimit-Reset, the latter in Unix seconds.

Errors omit those rate headers and Retry-After. See the complete rate-limit reference.

Error responses

CodeHTTPCauseFixRetryable?
LICENSE_NOT_FOUND404Management scoped license absentCorrect org/product/environment/IDNo blind retry; apply the correction
INVALID_STATE409Forbidden state transition or restore with elapsed expiryResolve state/renew firstNo blind retry; apply the correction
INTERNAL_ERROR500Uncaught exception at global boundarySafe retry only for idempotent operation; preserve request_idOnly safe reads after backoff; reconcile mutations
INVALID_API_KEY401Missing/invalid/revoked key or prohibited subscription/environmentReplace/configure keyNo blind retry; apply the correction
FORBIDDEN403Developer scope missing; checkout account role not OWNER/ADMINUse authorized scope/roleNo blind retry; apply the correction
RATE_LIMITED429Bucket exhausted; wait for window reset; no licensing Retry-After headerAfter window; apply jitterAfter the 60-second window, with jitter

An unregistered path or wrong method is handled by the global router as NOT_FOUND (HTTP 404), not405. Every licensing error has success=false, error.code, error.message and request_id. Errors keeps SDK-local and operational namespaces separate.

Side effects

Sets an eligible license ACTIVE and clears revocation_reason. An elapsed expiration must be renewed first; an EXPIRED stored status cannot directly restore. Old tokens remain revoked; a fresh activation is needed. SUSPENDED-to-ACTIVE produces audit/webhook license.restored. ACTIVE-to-ACTIVE and PENDING-to-ACTIVE produce audit license.active but no restoration webhook. No email is sent directly.

Authenticated requests can consume the organization monthly API usage counter once tenant context is established, including some failures. This usage counter is currently warning-only, not a monthly API rejection gate. Developer-key authentication can update last_used_at before a later failure. No request body or Authorization value is saved by the API metadata logger.

Idempotency and concurrency

Idempotency-Key is ignored. Repeating restore is not guaranteed to repeat the same event type: a formerly suspended license is now active. Updates use row locks without caller revision checks. A concurrent removal after the preliminary read yields INVALID_STATE.

Rate limits

Developer pre-authentication:240 per60 seconds per IP. Shared license-write bucket:60 per60 seconds per key across revoke, suspend, restore and renew.

Fixed windows begin with the first hit after expiry. Attempted calls consume every bucket they reach, even if later business validation fails.

Runnable examples

These are complete native HTTP transport programs, not full SDK clients or entitlement verifiers. JSON request bodies and credentials come from KDP_* environment variables. They print raw responses to a private terminal; do not send their stdout to application/CI logs. Use the P5 verification guides before granting access.

cURL

Save every file shown below. Install the exact runtime/dependencies from the complete example archive README. Set the endpoint request JSON in KDP_BODY_JSON and the documented KDP_* credential variables in your private process environment.

Run sh request.sh restore. Expected: full JSON, exit 0 for success, exit 1 for an API rejection; exit 2 for setup/transport failure. The cURL sample checks HTTP status; parse JSON before use. Never authorize a feature from transport output alone.

request.shbash
#!/bin/sh
# Purpose: inspect one Sandbox API operation; not signature verification.
# Requirements: POSIX sh, curl7.76+. Run: sh request.sh public-key
# Expected: JSON; exit0 HTTP2xx/1 HTTP rejection/2 setup or transport failure.
# KDP_* variables carry credentials/body. Output can contain newly issued secrets:
# use a private terminal only, never application/CI logs. Verify signed state separately.
set -eu
fail() { printf '%s\n' 'Check the operation and KDP_* configuration. Do not blindly retry mutations.' >&2; exit 2; }
[ "$#" -eq 1 ] || fail
name=$1
case "$name" in
  public-key) method='GET'; path='/public-key'; auth='public' ;;
  create-license) method='POST'; path='/licenses'; auth='developer' ;;
  activate) method='POST'; path='/licenses/activate'; auth='publicApp' ;;
  validate) method='POST'; path='/licenses/validate'; auth='activation' ;;
  deactivate) method='POST'; path='/licenses/deactivate'; auth='activation' ;;
  get-license) method='GET'; path='/licenses/{license}'; auth='developer' ;;
  revoke) method='POST'; path='/licenses/{license}/revoke'; auth='developer' ;;
  suspend) method='POST'; path='/licenses/{license}/suspend'; auth='developer' ;;
  restore) method='POST'; path='/licenses/{license}/restore'; auth='developer' ;;
  renew) method='POST'; path='/licenses/{license}/renew'; auth='developer' ;;
  reset-devices) method='POST'; path='/licenses/{license}/reset-devices'; auth='developer' ;;
  *) fail ;;
esac
base=${KDP_BASE_URL:-https://licensing.kdpika.com/api/v1}
base=${base%/}
case "$base" in *'@'*|*'?'*|*'#'*|*' '* ) fail ;; esac
case "$base" in
  https://*/api/v1) ;;
  http://127.0.0.1:*/api/v1|http://localhost:*/api/v1) [ "${KDP_ALLOW_LOOPBACK:-0}" = 1 ] || fail ;;
  *) fail ;;
esac
case "$path" in *'{license}'*)
  id=${KDP_LICENSE_ID:?Set KDP_LICENSE_ID}
  case "$id" in *[!A-Za-z0-9_-]*|'') fail ;; esac
  path=$(printf '%s' "$path" | sed "s/{license}/$id/") ;;
esac
set -- --silent --show-error --fail-with-body --connect-timeout 5 --max-time 15 --request "$method" \
  --header 'Accept: application/json' --header 'User-Agent: KDPikaDocsExample/1.0 curl'
case "$auth" in
  developer)
    case "${KDP_API_KEY:-}" in lmp_sandbox_*) ;; *) fail ;; esac
    set -- "$@" --header "Authorization: Bearer $KDP_API_KEY" ;;
  activation) set -- "$@" --header "Authorization: Bearer ${KDP_ACTIVATION_TOKEN:?Set KDP_ACTIVATION_TOKEN}" ;;
  publicApp) set -- "$@" --header "X-App-ID: ${KDP_APP_ID:?Set KDP_APP_ID}" --header 'X-Environment: SANDBOX' ;;
esac
if [ "$name" = create-license ]; then set -- "$@" --header "Idempotency-Key: ${KDP_IDEMPOTENCY_KEY:?Set KDP_IDEMPOTENCY_KEY}"; fi
if [ "$name" = validate ]; then set -- "$@" --header "X-Installation-ID: ${KDP_INSTALLATION_ID:?Set KDP_INSTALLATION_ID}"; fi
if [ "$method" = POST ]; then
  body=${KDP_BODY_JSON-'{}'}
  set -- "$@" --header 'Content-Type: application/json' --data-binary "$body"
fi
# Keep the response in memory only, separating the final status line. No file,
# --location, --insecure or --verbose. The caller must still inspect JSON success.
if response=$(curl "$@" --write-out '\n%{http_code}' "$base$path"); then transport=0; else transport=$?; fi
newline='
'
status=${response##*"$newline"}
payload=${response%"$newline"*}
case "$status" in [0-9][0-9][0-9]) ;; *) fail ;; esac
if [ "$transport" -ne 0 ] && [ "$transport" -ne 22 ]; then fail; fi
printf '%s\n' "$payload"
case "$status" in 2[0-9][0-9]) exit 0 ;; esac
printf '%s\n' 'The API did not accept the request. Inspect error.code/request_id; reconcile mutations before retrying.' >&2
exit 1

Expected result

A correctly authenticated eligible request returns the documented HTTP status and schema. Check the actual success/error result and request IDs; a successful transport or unsigned management response does not grant a feature.

Common mistakes

  • Mixing Public App IDs, internal product IDs and product-plan IDs.
  • Assuming a mutation timeout means no work committed, or assuming Idempotency-Key protects every action.
  • Logging raw responses that contain a newly issued license key or activation token.

Security notes

Keep lmp_ credentials out of shipped desktop/browser code. Verify signed payload bytes and product/environment/installation/status/time/feature policy. The examples do not fix the documented idempotency, cache canonicalization or current-key-only rotation limitations.

Troubleshooting

SymptomCauseAction
LICENSE_NOT_FOUND (HTTP 404)Management scoped license absentCorrect org/product/environment/ID
INVALID_STATE (HTTP 409)Forbidden state transition or restore with elapsed expiryResolve state/renew first
INTERNAL_ERROR (HTTP 500)Uncaught exception at global boundarySafe retry only for idempotent operation; preserve request_id
INVALID_API_KEY (HTTP 401)Missing/invalid/revoked key or prohibited subscription/environmentReplace/configure key
FORBIDDEN (HTTP 403)Developer scope missing; checkout account role not OWNER/ADMINUse authorized scope/role
RATE_LIMITED (HTTP 429)Bucket exhausted; wait for window reset; no licensing Retry-After headerAfter window; apply jitter

Next steps

Read idempotency and signed responses before integrating a purchase-to-license workflow.

Was this page helpful?

Choose an answer

Do not include personal data, license keys or credentials. Retained for up to 30 days. This is not a support inbox.

Search documentation

Arrow keys to move, Enter to open, Escape to close. Search stays in your browser.

Cookie settings