Skip to main content
POST
/
v1
/
products
/
Go (SDK)
package main

import(
	"context"
	"os"
	polargo "github.com/polarsource/polar-go"
	"github.com/polarsource/polar-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()

    s := polargo.New(
        polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
    )

    res, err := s.Products.Create(ctx, components.CreateProductCreateProductCreateOneTime(
        components.ProductCreateOneTime{
            Name: "<value>",
            Prices: []components.ProductCreateOneTimePrices{
                components.CreateProductCreateOneTimePricesProductPriceFixedCreate(
                    components.ProductPriceFixedCreate{
                        PriceAmount: 677078,
                    },
                ),
            },
            OrganizationID: polargo.Pointer("1dbfc517-0bbf-4301-9ba8-555ca42b9737"),
        },
    ))
    if err != nil {
        log.Fatal(err)
    }
    if res.Product != nil {
        // handle response
    }
}
{
  "id": "<string>",
  "created_at": "2023-11-07T05:31:56Z",
  "modified_at": "2023-11-07T05:31:56Z",
  "trial_interval": "day",
  "trial_interval_count": 123,
  "name": "<string>",
  "description": "<string>",
  "recurring_interval": "day",
  "is_recurring": true,
  "is_archived": true,
  "organization_id": "<string>",
  "metadata": {},
  "prices": [
    {
      "created_at": "2023-11-07T05:31:56Z",
      "modified_at": "2023-11-07T05:31:56Z",
      "id": "<string>",
      "amount_type": "<string>",
      "is_archived": true,
      "product_id": "<string>",
      "type": "<string>",
      "recurring_interval": "day",
      "price_currency": "<string>",
      "price_amount": 123,
      "legacy": true
    }
  ],
  "benefits": [
    {
      "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>"
      }
    }
  ],
  "medias": [
    {
      "id": "<string>",
      "organization_id": "<string>",
      "name": "<string>",
      "path": "<string>",
      "mime_type": "<string>",
      "size": 123,
      "storage_version": "<string>",
      "checksum_etag": "<string>",
      "checksum_sha256_base64": "<string>",
      "checksum_sha256_hex": "<string>",
      "last_modified_at": "2023-11-07T05:31:56Z",
      "version": "<string>",
      "service": "<string>",
      "is_uploaded": true,
      "created_at": "2023-11-07T05:31:56Z",
      "size_readable": "<string>",
      "public_url": "<string>"
    }
  ],
  "attached_custom_fields": [
    {
      "custom_field_id": "<string>",
      "custom_field": {
        "created_at": "2023-11-07T05:31:56Z",
        "modified_at": "2023-11-07T05:31:56Z",
        "id": "<string>",
        "metadata": {},
        "type": "<string>",
        "slug": "<string>",
        "name": "<string>",
        "organization_id": "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
        "properties": {
          "form_label": "<string>",
          "form_help_text": "<string>",
          "form_placeholder": "<string>",
          "textarea": true,
          "min_length": 1,
          "max_length": 1
        }
      },
      "order": 123,
      "required": true
    }
  ]
}

Authorizations

Authorization
string
header
required

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

Body

application/json
  • ProductCreateRecurring
  • ProductCreateOneTime
name
string
required

The name of the product.

Minimum length: 3
prices
ProductPriceCreateList · array
required

List of available prices for this product. It should contain at most one static price (fixed, custom or free), and any number of metered prices. Metered prices are not supported on one-time purchase products.

Minimum length: 1
  • ProductPriceFixedCreate
  • ProductPriceCustomCreate
  • ProductPriceFreeCreate
  • ProductPriceMeteredUnitCreate
recurring_interval
enum<string>
required

The recurring interval of the product. Note that the day and week values are for internal Polar staff use only.

Available options:
day,
week,
month,
year
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.

description
string | null

The description of the product.

medias
string<uuid4>[] | null

List of file IDs. Each one must be on the same organization as the product, of type product_media and correctly uploaded.

attached_custom_fields
AttachedCustomFieldCreate · object[]

List of custom fields to attach.

organization_id
string<uuid4> | null

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

Examples:

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

trial_interval
enum<string> | null

The interval unit for the trial period.

Available options:
day,
week,
month,
year
trial_interval_count
integer | null

The number of interval units for the trial period.

Required range: 1 <= x <= 1000

Response

Product created.

A product.

id
string<uuid4>
required

The ID of the object.

created_at
string<date-time>
required

Creation timestamp of the object.

modified_at
string<date-time> | null
required

Last modification timestamp of the object.

trial_interval
enum<string> | null
required

The interval unit for the trial period.

Available options:
day,
week,
month,
year
trial_interval_count
integer | null
required

The number of interval units for the trial period.

name
string
required

The name of the product.

description
string | null
required

The description of the product.

recurring_interval
enum<string> | null
required

The recurring interval of the product. If None, the product is a one-time purchase.Note that the day and week values are for internal Polar staff use only.

Available options:
day,
week,
month,
year
is_recurring
boolean
required

Whether the product is a subscription.

is_archived
boolean
required

Whether the product is archived and no longer available.

organization_id
string<uuid4>
required

The ID of the organization owning the product.

metadata
object
required
prices
Prices · array
required

List of prices for this product.

  • LegacyRecurringProductPriceFixed
  • LegacyRecurringProductPriceCustom
  • LegacyRecurringProductPriceFree
  • ProductPriceFixed
  • ProductPriceCustom
  • ProductPriceFree
  • ProductPriceMeteredUnit
benefits
Benefits · array
required

List of benefits granted by the product.

  • BenefitCustom
  • BenefitDiscord
  • BenefitGitHubRepository
  • BenefitDownloadables
  • BenefitLicenseKeys
  • BenefitMeterCredit
medias
ProductMediaFileRead · object[]
required

List of medias associated to the product.

attached_custom_fields
AttachedCustomField · object[]
required

List of custom fields attached to the product.

I