POST
/
v1
/
benefits
/
Typescript (SDK)
import { Polar } from "@polar-sh/sdk";

const polar = new Polar({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  const result = await polar.benefits.create({
    type: "license_keys",
    description: "mature emergent at outside arrogantly gadzooks zealous equatorial notwithstanding",
    properties: {},
  });

  console.log(result);
}

run();
{
  "id": "<string>",
  "created_at": "2023-11-07T05:31:56Z",
  "modified_at": "2023-11-07T05:31:56Z",
  "type": "<string>",
  "description": "<string>",
  "selectable": true,
  "deletable": true,
  "organization_id": "<string>",
  "metadata": {},
  "properties": {
    "note": "<string>"
  }
}

Authorizations

Authorization
string
header
required

You can generate an Organization Access Token from your organization's settings.

Body

application/json

Schema to create a benefit of type custom.

type
string
required
Allowed value: "custom"
description
string
required

The description of the benefit. Will be displayed on products having this benefit.

Required string length: 3 - 42
properties
object
required

Properties for creating a benefit of type custom.

metadata
object

Key-value object allowing you to store additional information.

The key must be a string with a maximum length of 40 characters. The value must be either:

  • A string with a maximum length of 500 characters
  • An integer
  • A floating-point number
  • A boolean

You can store up to 50 key-value pairs.

organization_id
string<uuid4> | null

The ID of the organization owning the benefit. Required unless you use an organization token. The organization ID.

Examples:

"1dbfc517-0bbf-4301-9ba8-555ca42b9737"

Response

Benefit created.

A benefit of type custom.

Use it to grant any kind of benefit that doesn't fit in the other types.

id
string<uuid4>
required

The ID of the benefit.

created_at
string<date-time>
required

Creation timestamp of the object.

modified_at
string<date-time> | null
required

Last modification timestamp of the object.

type
string
required
Allowed value: "custom"
description
string
required

The description of the benefit.

selectable
boolean
required

Whether the benefit is selectable when creating a product.

deletable
boolean
required

Whether the benefit is deletable.

organization_id
string<uuid4>
required

The ID of the organization owning the benefit.

metadata
object
required
properties
object
required

Properties for a benefit of type custom.