Generate a purchase code
const url = 'https://partner-pcode-dev.tsp.workers.dev/api/partner/v1/pcode';const options = { method: 'POST', headers: {'x-gw': '<x-gw>', 'Content-Type': 'application/json'}, body: '{"productCode":"FV00","external_reference_id":"example","force_new":false}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://partner-pcode-dev.tsp.workers.dev/api/partner/v1/pcode \ --header 'Content-Type: application/json' \ --header 'x-gw: <x-gw>' \ --data '{ "productCode": "FV00", "external_reference_id": "example", "force_new": false }'If external_reference_id is sent and a still-valid purchase code (unused, not blocked, within its 14-day window) already exists for that same reference, that SAME purchase code is returned (reused: true) instead of creating a new one — unless force_new: true is passed, which also voids any previous purchase code under that reference.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
FV00=6 months, FV01=1 year, FV02=2 years, FV03=3 years.
The partner’s own identifier, for idempotency.
Responses
Section titled “ Responses ”Purchase code created (or reused — see data.reused).
object
object
Example
{ "success": true, "data": { "status": "ACTIVE" }}Invalid/missing productCode, or the partner doesn’t have that product enabled (partner_config.allowed_products — if that column is NULL or no config row exists, there’s no restriction and any valid productCode passes).
object
Example
{ "success": false}Invalid API Key.
Rate limit exceeded (60 requests/60s per partner).