Developer documentation

Assign product

post https://app.iteras.dk/api/customers/assignproduct/

The /api/customers/assignproduct/ endpoint assigns a product to a customer or subscription.

If you have a subscription with products, you can assign a product to one of the periods of the subscription by filling in subscription_id and period. The assigned product must belong to the same category as what the subscription subscribes to.

You can also assign an individual product directly to a customer, e.g. if signing up a customer to an event. Here you should not fill subscription_id.

Parameters

  • id string required
    ID of the customer.
  • subscription_id string
    ID of the subscription to assign the product to.
  • period string
    The period to assign the product to. Either current or the index of the period, with the oldest period first, e.g. 1 for the first period. Required when subscription_id is given.
  • name string
    The name of the product to assign. Either name or external_id must be given.
  • external_id string
    The external ID of the product to assign. Either name or external_id must be given.
  • data object
    Any attributes to attach to the product assignment. The valid attributes are the fields that are associated with the product assignment.

You can set any custom product assignment field, using its field id (the field name with a colon prepended, or its external identifier).

Log in, or send your API key as a bearer token, to see the custom product assignment fields set up for your account.

Examples

Assign an individual product to a period, using external_id as key:

POST /api/customers/assignproduct/ HTTP/1.1
Content-Type: application/json{
  "id": "12345",
  "subscription_id": "32142532",
  "period": "current",
  "external_id": "example-product"
}

Assign an event product directly to a customer:

POST /api/customers/assignproduct/ HTTP/1.1
Content-Type: application/json{
  "id": "12345",
  "external_id": "example-product",
  "data": {
    ":Custom product assignment field": "Eksempeltekst",
    ":Custom date field": "2026-09-09"
  }
}

The endpoint returns the ID of the new product assignment:

{ "product_assignment_id": "9989892798" }

Errors

Invalid requests due to programming error, e.g. invalid JSON, returns 400. This also covers giving neither name nor external_id.

A well-formed operation where a supplied value is invalid is not executed and returns an HTTP 422 error. The response is a JSON object with the errors keyed by the field they concern, e.g. a custom product assignment field:

{
  ":Custom product assignment field": ["Enter a valid value."]
}

Errors that are not specific to a field are returned with the empty string as key. This covers an unknown product, subscription or period, a product that doesn't match the category the subscription subscribes to, and a recurring product:

{
  "": ["Product does not exist."]
}