---
title: "Records a key a customer holds from another platform as their license to a software product, so software in the field keeps checking; it may land disabled, or take the place of the customer's license."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.sherpo.io/llms.txt
> Use this file to discover all available pages before exploring further.

Path: Sherpo merchant API › customer

`POST /v1/stores/{store}/products/{product}/licenses`

## Authentication

- `bearer`, http, header `Authorization`, scopes: `customer:write`

## Path parameters

- `store` (`recordLicense.path.store`; string, required) — The store's id.
- `product` (`recordLicense.path.product`; string, required) — An id, or `slug:<slug>`.
  - minLength 1

## Header parameters

- `Idempotency-Key` (`recordLicense.header.Idempotency-Key`; string, optional) — Repeats within 24 hours answer the first result; the same key with other arguments is a conflict.
  - minLength 1; maxLength 255; pattern `^[\x21-\x7E]+$`

## Request body

_Required._

- `customer` (`recordLicense.customer`; any of, required) — By id, or by email: whoever the address reaches, else a new invited customer.
  - any of: `object`, `object`
- `key` (`recordLicense.key`; string, required) — The key as the old platform issued it, kept verbatim; a hex key matches in any case and spacing, any other exactly.
  - minLength 6; maxLength 128; pattern `^[A-Za-z0-9._-]*[A-Za-z0-9][A-Za-z0-9._-]*$`
- `uses` (`recordLicense.uses`; integer, optional) — How many times software checked it so far; a replace keeps the replaced license's by default.
  - min 0; max 1000000000
- `metadata` (`recordLicense.metadata`; map<any of>, optional)
- `disabled` (`recordLicense.disabled`; boolean, optional) — Record it disabled, as for a key refunded or turned off at the old platform; defaults to false, or to the replaced license's state.
- `disabled_reason` (`recordLicense.disabled_reason`; any of, optional) — Why it is disabled; only with `disabled`.
  - any of: `string`, `null`
- `replace` (`recordLicense.replace`; boolean, optional) — Take the place of the customer's live license for the product, keeping its limit, which then reads as replaced. Defaults to false.

## Example request

```json
{
  "customer": {
    "id": "string"
  },
  "key": "string",
  "uses": 1000000000,
  "metadata": {
    "property1": true,
    "property2": true
  },
  "disabled": true,
  "disabled_reason": "string",
  "replace": true
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url 'https://api.sherpo.io/merchant/v1/stores/<store>/products/<product>/licenses' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "customer": {
    "id": "string"
  },
  "key": "string",
  "uses": 1000000000,
  "metadata": {
    "property1": true,
    "property2": true
  },
  "disabled": true,
  "disabled_reason": "string",
  "replace": true
}
'
```

### TypeScript

```typescript
const url = 'https://api.sherpo.io/merchant/v1/stores/<store>/products/<product>/licenses';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({
    customer: {id: 'string'},
    key: 'string',
    uses: 1000000000,
    metadata: {property1: true, property2: true},
    disabled: true,
    disabled_reason: 'string',
    replace: true
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.sherpo.io/merchant/v1/stores/<store>/products/<product>/licenses"

payload = {
    "customer": { "id": "string" },
    "key": "string",
    "uses": 1000000000,
    "metadata": {
        "property1": True,
        "property2": True
    },
    "disabled": True,
    "disabled_reason": "string",
    "replace": True
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 201

Records a key a customer holds from another platform as their license to a software product, so software in the field keeps checking; it may land disabled, or take the place of the customer's license.

#### Example

```json
{
  "subscription": {
    "id": "string",
    "status": "string",
    "current_period_end": "string",
    "cancel_at_period_end": true,
    "ended_at": "string"
  },
  "activations": {
    "count": 0,
    "limit": 0
  },
  "key_ending": "string",
  "tier": {
    "id": "string",
    "name": "string",
    "rank": 0
  },
  "customer": {
    "id": "string",
    "name": "string",
    "email": "string",
    "phone": "string",
    "erased": true
  },
  "id": "string",
  "product_id": "string",
  "customer_id": "string",
  "source": "string",
  "status": "string",
  "expires_at": "string",
  "reason": "string",
  "has_access": true,
  "activation_limit": 0,
  "uses": 0,
  "metadata": {
    "property1": true,
    "property2": true
  },
  "created_at": "string",
  "disabled_at": "string",
  "disabled_reason": "string",
  "replaced_by": "string",
  "last_verified_at": "string"
}
```

- `subscription` (`recordLicense.response.201.subscription`; any of, required) — The subscription behind its access; null for a one-time purchase or a grant, or without `subscription:read`.
  - any of: `object`, `null`
- `activations` (`recordLicense.response.201.activations`; object, required) — The devices it counts now and the most it may hold, its own limit, else its tier's, else its product's; `limit` null when nothing limits it.
  - `count` (`recordLicense.response.201.activations.count`; number, required)
  - `limit` (`recordLicense.response.201.activations.limit`; any of, required)
    - any of: `number`, `null`
- `key_ending` (`recordLicense.response.201.key_ending`; string, required) — The key's last characters, so a support reply can name it; `getLicense` answers it whole.
- `tier` (`recordLicense.response.201.tier`; any of, required) — The tier its access opens, else the one it last opened; null for access with no tier.
  - any of: `object`, `null`
- `customer` (`recordLicense.response.201.customer`; any of, required)
  - any of: `object`, `null`
- `id` (`recordLicense.response.201.id`; string, required)
- `product_id` (`recordLicense.response.201.product_id`; string, required)
- `customer_id` (`recordLicense.response.201.customer_id`; string, required)
- `source` (`recordLicense.response.201.source`; string, required)
- `status` (`recordLicense.response.201.status`; string, required) — Where it stands now: `active`, `expired`, `revoked`, `disabled` or `replaced`.
- `expires_at` (`recordLicense.response.201.expires_at`; any of, required) — When access ends; null while it never does.
  - any of: `string`, `null`
- `reason` (`recordLicense.response.201.reason`; any of, required) — Why it reads its status: `replaced`, `disabled`, `lapse`, `refund` or `revoke`; null while active, or before any access began.
  - any of: `string`, `null`
- `has_access` (`recordLicense.response.201.has_access`; boolean, required) — Whether its holder has access now, whatever its status; false before access begins.
- `activation_limit` (`recordLicense.response.201.activation_limit`; any of, required)
  - any of: `number`, `null`
- `uses` (`recordLicense.response.201.uses`; number, required)
- `metadata` (`recordLicense.response.201.metadata`; map<any of>, required)
- `created_at` (`recordLicense.response.201.created_at`; any of, required)
  - any of: `string`, `null`
- `disabled_at` (`recordLicense.response.201.disabled_at`; any of, required)
  - any of: `string`, `null`
- `disabled_reason` (`recordLicense.response.201.disabled_reason`; any of, required)
  - any of: `string`, `null`
- `replaced_by` (`recordLicense.response.201.replaced_by`; any of, required)
  - any of: `string`, `null`
- `last_verified_at` (`recordLicense.response.201.last_verified_at`; any of, required)
  - any of: `string`, `null`

### default

A problem; see https://api.sherpo.io/merchant/docs/errors.

#### Example

```json
{
  "type": "http://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "string",
  "context": {},
  "reached_core": true,
  "core_answer": "string"
}
```

- `type` (`recordLicense.response.default.type`; string, required)
  - format `uri`
- `title` (`recordLicense.response.default.title`; string, required)
- `status` (`recordLicense.response.default.status`; integer, required)
- `detail` (`recordLicense.response.default.detail`; string, required)
- `code` (`recordLicense.response.default.code`; string, optional)
- `context` (`recordLicense.response.default.context`; object, optional)
- `reached_core` (`recordLicense.response.default.reached_core`; boolean, optional)
- `core_answer` (`recordLicense.response.default.core_answer`; string, optional)


Source: https://docs.sherpo.io/merchant-api/reference/record-license/index.md
