POST
/
v1
/
products
/
{id}
/
benefits
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.UpdateBenefits(ctx, "<value>", components.ProductBenefitsUpdate{
        Benefits: []string{
            "<value>",
        },
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Product != nil {
        // handle response
    }
}
{
  "created_at": "2023-11-07T05:31:56Z",
  "modified_at": "2023-11-07T05:31:56Z",
  "id": "<string>",
  "name": "<string>",
  "description": "<string>",
  "recurring_interval": "month",
  "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": "month",
      "price_currency": "<string>",
      "price_amount": 123,
      "legacy": true
    }
  ],
  "benefits": [
    {
      "created_at": "2023-11-07T05:31:56Z",
      "modified_at": "2023-11-07T05:31:56Z",
      "id": "<string>",
      "type": "<string>",
      "description": "<string>",
      "selectable": true,
      "deletable": true,
      "organization_id": "<string>",
      "properties": {
        "image_height": 400,
        "image_width": 400
      }
    }
  ],
  "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": "<string>",
        "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

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

id
string
required

The product ID.

Body

application/json

Schema to update the benefits granted by a product.

benefits
string[]
required

List of benefit IDs. Each one must be on the same organization as the product.

Response

200
application/json
Product benefits updated.

A product.

created_at
string
required

Creation timestamp of the object.

modified_at
string | null
required

Last modification timestamp of the object.

id
string
required

The ID of the product.

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.

Available options:
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
required

The ID of the organization owning the product.

metadata
object
required
prices
object[]
required

List of prices for this product.

benefits
object[]
required

List of benefits granted by the product.

medias
object[]
required

List of medias associated to the product.

attached_custom_fields
object[]
required

List of custom fields attached to the product.

Was this page helpful?