Retrieve the current public verification key.
What you will learn
- Send this exact operation with its required credentials and fields.
- Interpret success, refusal, side effects and retry risks.
Prerequisites
- Complete the Sandbox quickstart.
- Read API conventions and authentication.
- Keep customer credentials private and management keys on your trusted backend.
Method and path
GET /api/v1/public-key
When to use it
Fetch the current Ed25519 verification key during a trusted setup or controlled key refresh. This endpoint is global, not specific to an organization or environment.
Authentication and environment
No credential or environment header is required.
Request headers
| Header | Required | Description | Example |
|---|---|---|---|
| Accept | recommended | JSON responses | application/json |
Path and query parameters
No path parameters are accepted.
No pagination, filtering, sorting or list query parameters are implemented. Use JSON rather than relying on alternate form/query parsing.
Request body
No request body is consumed. Send this GET request without a body.
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.
{
"success": true,
"key": {
"algorithm": "Ed25519",
"key_id": "ed25519_2b9bc7e214b1209f",
"public_key": "3VNX3t2NIvzg37o1w-bjxJdJVFtgbfpR-_Q80u4U5tQ",
"encoding": "base64url"
},
"request_id": "req_d9e278f6722a692a5dc3bbe8"
}
Response fields
| Field | Type | Required | Constraints | Description | Example |
|---|---|---|---|---|---|
| success | boolean | yes | const=true | The operation succeeded. | true |
| key | object | yes | See description | Current global verification key, not a historical key ring. | Nested object/array shown in full JSON |
| key.algorithm | string | yes | const="Ed25519" | Fixed verification algorithm. | "Ed25519" |
| key.key_id | string | yes | pattern="^ed25519_[a-f0-9]{16}$" | ed25519_ plus first16 hex SHA256 characters of raw public key. | "ed25519_2b9bc7e214b1209f" |
| key.public_key | string | yes | pattern="^[A-Za-z0-9_-]{43}$" | Unpadded base64url of32 raw Ed25519 public-key bytes. | "3VNX3t2NIvzg37o1w-bjxJdJVFtgbfpR-_Q80u4U5tQ" |
| key.encoding | string | yes | const="base64url" | Raw-key encoding. | "base64url" |
| request_id | string | yes | pattern="^req_[a-f0-9]{24}$" | Request correlation ID. Replay bodies can retain an earlier ID. | "req_d9e278f6722a692a5dc3bbe8" |
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
| Code | HTTP | Cause | Fix | Retryable? |
|---|---|---|---|---|
| RATE_LIMITED | 429 | Bucket exhausted; wait for window reset; no licensing Retry-After header | After window; apply jitter | After the 60-second window, with jitter |
| INTERNAL_ERROR | 500 | Uncaught exception at global boundary | Safe retry only for idempotent operation; preserve request_id | Only safe reads after backoff; reconcile mutations |
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
No license, device, token, customer, audit event, webhook or email is created. The public-key IP limiter is consumed. The global API metadata log has no organization attribution.
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
GET is safe to retry with bounded backoff. Cache the successful key for the advertised3600 seconds, subject to your pinned-key refresh policy. A timeout never justifies disabling verification. The endpoint returns only the current key, not a historical key ring.
Rate limits
60 requests per60 seconds, keyed by the caller IP.
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.
Swift
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 ./request public-key. 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.
// Purpose: inspect one client-callable Sandbox operation, not grant feature access.
// Requires Swift5.7+, Foundation; FoundationNetworking on Linux.
// Build: swiftc -parse-as-library request.swift -o request; run: ./request public-key
// Expected: JSON; exit0 success/1 API rejection/2 setup or transport failure.
// Credentials/body: KDP_* variables. Private terminal only; output may contain secrets.
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
let contract = #"""
{
"public-key": {
"method": "GET",
"path": "/public-key",
"auth": "public"
},
"activate": {
"method": "POST",
"path": "/licenses/activate",
"auth": "publicApp"
},
"validate": {
"method": "POST",
"path": "/licenses/validate",
"auth": "activation"
},
"deactivate": {
"method": "POST",
"path": "/licenses/deactivate",
"auth": "activation"
}
}
"""#
enum SetupError: Error {case invalid}
func required(_ name:String) throws -> String {
let value=ProcessInfo.processInfo.environment[name] ?? ""
guard !value.isEmpty && !value.contains("\r") && !value.contains("\n") else {throw SetupError.invalid};return value
}
final class NoRedirect: NSObject, URLSessionTaskDelegate, @unchecked Sendable {
func urlSession(_ session:URLSession,task:URLSessionTask,willPerformHTTPRedirection response:HTTPURLResponse,newRequest request:URLRequest,completionHandler:@escaping(URLRequest?)->Void){completionHandler(nil)}
}
@main struct Example {
static func main() async {
do {
let env=ProcessInfo.processInfo.environment
let operations=try JSONSerialization.jsonObject(with:Data(contract.utf8)) as! [String:[String:String]]
guard CommandLine.arguments.count==2,let op=operations[CommandLine.arguments[1]] else {throw SetupError.invalid}
let name=CommandLine.arguments[1]
let base=(env["KDP_BASE_URL"] ?? "https://licensing.kdpika.com/api/v1").replacingOccurrences(of:"/+$",with:"",options:.regularExpression)
guard let parts=URLComponents(string:base),let host=parts.host else {throw SetupError.invalid}
let local=parts.scheme=="http" && ["localhost","127.0.0.1"].contains(host) && env["KDP_ALLOW_LOOPBACK"]=="1"
guard (parts.scheme=="https" || local) && parts.user==nil && parts.password==nil && parts.query==nil && parts.fragment==nil && parts.path=="/api/v1",let url=URL(string:base+op["path"]!) else {throw SetupError.invalid}
var request=URLRequest(url:url);request.httpMethod=op["method"];request.timeoutInterval=15
request.setValue("application/json",forHTTPHeaderField:"Accept");request.setValue("KDPikaDocsExample/1.0 Swift",forHTTPHeaderField:"User-Agent")
if op["auth"]=="publicApp" {request.setValue(try required("KDP_APP_ID"),forHTTPHeaderField:"X-App-ID");request.setValue("SANDBOX",forHTTPHeaderField:"X-Environment")}
if op["auth"]=="activation" {request.setValue("Bearer "+(try required("KDP_ACTIVATION_TOKEN")),forHTTPHeaderField:"Authorization")}
if name=="validate" {request.setValue(try required("KDP_INSTALLATION_ID"),forHTTPHeaderField:"X-Installation-ID")}
if op["method"]=="POST" {
let body=Data((env["KDP_BODY_JSON"] ?? "{}").utf8)
guard try JSONSerialization.jsonObject(with:body) is [String:Any] else {throw SetupError.invalid}
request.httpBody=body;request.setValue("application/json",forHTTPHeaderField:"Content-Type")
}
let session=URLSession(configuration:.ephemeral,delegate:NoRedirect(),delegateQueue:nil)
defer {session.invalidateAndCancel()}
let (raw,response)=try await session.data(for:request)
guard let http=response as? HTTPURLResponse,let result=try JSONSerialization.jsonObject(with:raw) as? [String:Any],let text=String(data:raw,encoding:.utf8) else {throw SetupError.invalid}
_ = text // Decoding above checks UTF-8 without reserializing JSON.
FileHandle.standardOutput.write(raw);FileHandle.standardOutput.write(Data([10]))
guard (200..<300).contains(http.statusCode),result["success"] as? Bool == true else {
FileHandle.standardError.write(Data("API rejection. Inspect error.code/request_id; reconcile mutations before retrying.\n".utf8));exit(1)
}
} catch {
FileHandle.standardError.write(Data("Request unavailable or configuration invalid. Check KDP_* settings/connectivity; do not blindly retry mutations.\n".utf8));exit(2)
}
}
}
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
| Symptom | Cause | Action |
|---|---|---|
| RATE_LIMITED (HTTP 429) | Bucket exhausted; wait for window reset; no licensing Retry-After header | After window; apply jitter |
| INTERNAL_ERROR (HTTP 500) | Uncaught exception at global boundary | Safe retry only for idempotent operation; preserve request_id |
Next steps
Read idempotency and signed responses before integrating a purchase-to-license workflow.