POST
/
v1
/
custom-fields
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.CustomFields.Create(ctx, components.CreateCustomFieldCreateSelect(
        components.CustomFieldCreateSelect{
            Slug: "<value>",
            Name: "<value>",
            Properties: components.CustomFieldSelectProperties{
                Options: []components.CustomFieldSelectOption{
                    components.CustomFieldSelectOption{
                        Value: "<value>",
                        Label: "<value>",
                    },
                },
            },
        },
    ))
    if err != nil {
        log.Fatal(err)
    }
    if res.CustomField != nil {
        // handle response
    }
}
{
  "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
  }
}

Authorizations

Authorization
string
header
required

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

Body

application/json

Schema to create a custom field of type text.

type
string
required
Allowed value: "text"
slug
string
required

Identifier of the custom field. It'll be used as key when storing the value. Must be unique across the organization.It can only contain ASCII letters, numbers and hyphens.

Minimum length: 1
name
string
required

Name of the custom field.

Minimum length: 1
properties
object
required
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 boolean

You can store up to 50 key-value pairs.

organization_id
string | null

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

Response

201
application/json
Custom field created.

Schema for a custom field of type text.

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 object.

metadata
object
required
type
string
required
Allowed value: "text"
slug
string
required

Identifier of the custom field. It'll be used as key when storing the value.

name
string
required

Name of the custom field.

organization_id
string
required

The ID of the organization owning the custom field.

properties
object
required