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.CreateProductCreateOneTimePricesCustom(
                    components.ProductPriceCustomCreate{},
                ),
            },
            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",
  "recurring_interval_count": 123,
  "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>",
      "source": "catalog",
      "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

Body

application/json
  • ProductCreateRecurring
  • ProductCreateOneTime
name
string
required
Minimum length: 3
prices
ProductPriceCreateList · array
required
Minimum length: 1
  • ProductPriceFixedCreate
  • ProductPriceCustomCreate
  • ProductPriceFreeCreate
  • ProductPriceSeatBasedCreate
  • ProductPriceMeteredUnitCreate
recurring_interval
enum<string>
required
Available options:
day,
week,
month,
year
metadata
object
description
string | null
medias
string<uuid4>[] | null
attached_custom_fields
AttachedCustomFieldCreate · object[]
organization_id
string<uuid4> | null
Examples:
trial_interval
enum<string> | null
Available options:
day,
week,
month,
year
trial_interval_count
integer | null
Required range: 1 <= x <= 1000
recurring_interval_count
integer
default:1
Required range: 1 <= x <= 999

Response

id
string<uuid4>
required
created_at
string<date-time>
required
modified_at
string<date-time> | null
required
trial_interval
enum<string> | null
required
Available options:
day,
week,
month,
year
trial_interval_count
integer | null
required
name
string
required
description
string | null
required
recurring_interval
enum<string> | null
required
Available options:
day,
week,
month,
year
recurring_interval_count
integer | null
required
is_recurring
boolean
required
is_archived
boolean
required
organization_id
string<uuid4>
required
metadata
object
required
prices
Prices · array
required
  • LegacyRecurringProductPriceFixed
  • LegacyRecurringProductPriceCustom
  • LegacyRecurringProductPriceFree
  • ProductPriceFixed
  • ProductPriceCustom
  • ProductPriceFree
  • ProductPriceSeatBased
  • ProductPriceMeteredUnit
benefits
Benefits · array
required
  • BenefitCustom
  • BenefitDiscord
  • BenefitGitHubRepository
  • BenefitDownloadables
  • BenefitLicenseKeys
  • BenefitMeterCredit
medias
ProductMediaFileRead · object[]
required
attached_custom_fields
AttachedCustomField · object[]
required