# POST /products/{{product_id}}/licenses — Create License

> Product: **Pabbly Subscription Billing** (v1)
> Base URL: `https://payments.pabbly.com/api/v1`
> Auth: Basic via `Authorization` header
> Canonical: `/subscription-billing/licenses/create-license`

Fire the link with POST request and fill the following details in from data. If the response status is success then a license code will be generated for that customer. Attributes ::

**Path parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| product_id | string | Yes |  |

**Body parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| name | string | Yes | License Name |
| plan_id | string | No |  |
| method | string | Yes | List/Auto-generated |
| license_codes | string | No |  |
| status | string | Yes | Active |
| Plan ID | string | Yes | Add the Plan for which you want to create License codes |
| License Codes | string | Yes | Add license code names that you want to add to the list and provide it to customers |

**Example request body:**

```json
{
    "name":"Pabbly connect",
    "plan_id":"5fa102de8a9cd93f37cd768f",
    "method":"list",
    "license_codes":"FIRSTCODE1\nSECONDCODE2\nTHIRDCODE3",
    "status":"active"
}
```

**Response (200)** — Create License:

```json
{
    "status": "success",
    "message": "License is created successfully",
    "data": {
        "createdAt": "2021-01-28T05:55:36.772Z",
        "updatedAt": "2021-01-28T05:55:36.772Z",
        "id": "601251d87948fe7864c0af15",
        "product_id": "5f912e619ede59558fab0ab0",
        "name": "Pabbly connect",
        "method": "list",
        "license_codes": "FIRSTCODE1\nSECONDCODE2\nTHIRDCODE3",
        "plan_id": "5fa102de8a9cd93f37cd768f",
        "status": "active"
    }
}
```

**Code examples:**

_cURL_

```curl
curl -X POST https://payments.pabbly.com/api/v1/products/{{product_id}}/licenses \
  -u {{YOUR_API_KEY}}:{{YOUR_SECRET_KEY}} \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Pabbly connect",
    "plan_id": "5fa102de8a9cd93f37cd768f",
    "method": "list",
    "license_codes": "FIRSTCODE1\nSECONDCODE2\nTHIRDCODE3",
    "status": "active"
  }'
```

_Ruby_

```ruby
require 'net/http'
require 'json'

uri = URI('https://payments.pabbly.com/api/v1/products/{{product_id}}/licenses')
request = Net::HTTP::Post.new(uri)
request.basic_auth '{{YOUR_API_KEY}}', '{{YOUR_SECRET_KEY}}'
request['Content-Type'] = 'application/json'
request.body = "{\"name\":\"Pabbly connect\",\"plan_id\":\"5fa102de8a9cd93f37cd768f\",\"method\":\"list\",\"license_codes\":\"FIRSTCODE1\\nSECONDCODE2\\nTHIRDCODE3\",\"status\":\"active\"}"

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
  http.request(request)
end

data = JSON.parse(response.body)
```

_Python_

```python
import requests
from requests.auth import HTTPBasicAuth

response = requests.post(
    'https://payments.pabbly.com/api/v1/products/{{product_id}}/licenses',
    auth=HTTPBasicAuth('{{YOUR_API_KEY}}', '{{YOUR_SECRET_KEY}}'),
    json={
    'name': 'Pabbly connect',
    'plan_id': '5fa102de8a9cd93f37cd768f',
    'method': 'list',
    'license_codes': 'FIRSTCODE1\nSECONDCODE2\nTHIRDCODE3',
    'status': 'active'
},
)

data = response.json()
```

_PHP_

```php
<?php
$ch = curl_init('https://payments.pabbly.com/api/v1/products/{{product_id}}/licenses');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_USERPWD, '{{YOUR_API_KEY}}:{{YOUR_SECRET_KEY}}');
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"name":"Pabbly connect","plan_id":"5fa102de8a9cd93f37cd768f","method":"list","license_codes":"FIRSTCODE1\nSECONDCODE2\nTHIRDCODE3","status":"active"}');

$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
```

_Java_

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.Base64;

String credentials = Base64.getEncoder().encodeToString("{{YOUR_API_KEY}}:{{YOUR_SECRET_KEY}}".getBytes());

HttpClient client = HttpClient.newHttpClient();
HttpRequest.Builder builder = HttpRequest.newBuilder()
    .uri(URI.create("https://payments.pabbly.com/api/v1/products/{{product_id}}/licenses"))
    .header("Authorization", "Basic " + credentials)
    .header("Content-Type", "application/json")
    .method("POST", HttpRequest.BodyPublishers.ofString("{\"name\":\"Pabbly connect\",\"plan_id\":\"5fa102de8a9cd93f37cd768f\",\"method\":\"list\",\"license_codes\":\"FIRSTCODE1\nSECONDCODE2\nTHIRDCODE3\",\"status\":\"active\"}"));

HttpRequest request = builder.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

_Node.js_

```node
const credentials = Buffer.from('{{YOUR_API_KEY}}:{{YOUR_SECRET_KEY}}').toString('base64');

const response = await fetch('https://payments.pabbly.com/api/v1/products/{{product_id}}/licenses', {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${credentials}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "name": "Pabbly connect",
    "plan_id": "5fa102de8a9cd93f37cd768f",
    "method": "list",
    "license_codes": "FIRSTCODE1\nSECONDCODE2\nTHIRDCODE3",
    "status": "active"
  }),
});

const data = await response.json();
```

_Go_

```go
package main

import (
    "fmt"
    "io"
    "net/http"
    "strings"
)

func main() {
    payload := strings.NewReader("{\"name\":\"Pabbly connect\",\"plan_id\":\"5fa102de8a9cd93f37cd768f\",\"method\":\"list\",\"license_codes\":\"FIRSTCODE1\\nSECONDCODE2\\nTHIRDCODE3\",\"status\":\"active\"}")
    req, _ := http.NewRequest("POST", "https://payments.pabbly.com/api/v1/products/{{product_id}}/licenses", payload)
    req.Header.Set("Content-Type", "application/json")
    req.SetBasicAuth("{{YOUR_API_KEY}}", "{{YOUR_SECRET_KEY}}")

    res, _ := http.DefaultClient.Do(req)
    defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)
    fmt.Println(string(body))
}
```

_.NET_

```dotnet
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

var credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes("{{YOUR_API_KEY}}:{{YOUR_SECRET_KEY}}"));

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://payments.pabbly.com/api/v1/products/{{product_id}}/licenses");
request.Headers.TryAddWithoutValidation("Authorization", $"Basic {credentials}");
request.Content = new StringContent("{\"name\":\"Pabbly connect\",\"plan_id\":\"5fa102de8a9cd93f37cd768f\",\"method\":\"list\",\"license_codes\":\"FIRSTCODE1\nSECONDCODE2\nTHIRDCODE3\",\"status\":\"active\"}");
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

var response = await client.SendAsync(request);
var data = await response.Content.ReadAsStringAsync();
Console.WriteLine(data);
```

---

**Other endpoints in Licenses:**

- [PUT /products/{{product_id}}/licenses/{{license_id}} — Update License](/subscription-billing/licenses/update-license)
- [GET /products/{{product_id}}/licenses — List All Licenses](/subscription-billing/licenses/list-all-licenses)
- [GET /products/{{product_id}}/licenses/{{license_id}} — Get Single License](/subscription-billing/licenses/get-single-license)
- [GET /products/{{product_id}}/licenses/{{license_id}}/codes — Get License Codes](/subscription-billing/licenses/get-license-codes)
- [DELETE /products/{{product_id}}/licenses/{{license_id}} — Delete License](/subscription-billing/licenses/delete-license)
- [DELETE /products/{{product_id}}/licenses/{{license_id}}/codes/{{code}} — Delete License Code](/subscription-billing/licenses/delete-license-code)

