Skip to main content
PATCH
/
v1
/
benefits
/
{id}
Go (SDK)
package main

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

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

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

    res, err := s.Benefits.Update(ctx, "<value>", operations.CreateBenefitsUpdateBenefitUpdateBenefitCustomUpdate(
        components.BenefitCustomUpdate{},
    ))
    if err != nil {
        log.Fatal(err)
    }
    if res.Benefit != nil {
        switch res.Benefit.Type {
            case components.BenefitUnionTypeCustom:
                // res.Benefit.BenefitCustom is populated
            case components.BenefitUnionTypeDiscord:
                // res.Benefit.BenefitDiscord is populated
            case components.BenefitUnionTypeDownloadables:
                // res.Benefit.BenefitDownloadables is populated
            case components.BenefitUnionTypeFeatureFlag:
                // res.Benefit.BenefitFeatureFlag is populated
            case components.BenefitUnionTypeGithubRepository:
                // res.Benefit.BenefitGitHubRepository is populated
            case components.BenefitUnionTypeLicenseKeys:
                // res.Benefit.BenefitLicenseKeys is populated
            case components.BenefitUnionTypeMeterCredit:
                // res.Benefit.BenefitMeterCredit is populated
        }

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

Documentation Index

Fetch the complete documentation index at: https://polar.sh/docs/llms.txt

Use this file to discover all available pages before exploring further.

Authorizations

Authorization
string
header
required

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

Path Parameters

id
string<uuid4>
required

The benefit ID.

Body

application/json
type
string
required
Allowed value: "custom"
metadata
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 benefit. Will be displayed on products having this benefit.

Required string length: 3 - 42
properties
BenefitCustomProperties · object

Properties for a benefit of type custom.

Response

Benefit updated.

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.

is_deleted
boolean
required

Whether the benefit is deleted.

organization_id
string<uuid4>
required

The ID of the organization owning the benefit.

metadata
object
required
properties
BenefitCustomProperties · object
required

Properties for a benefit of type custom.