Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Create an attribute based shipping option

Creates a new attribute based shipping option by linking an existing shipping option to a rule and a calculator.

The shipping_option field takes the identifier of an existing shipping option; if no shipping option with that identifier exists, the request fails with a validation error. The same shipping option may be linked more than once, which is how a single shipping option is offered with different rules or prices per attribute group.

To make the option eligible for every item group, send rule as an empty object ({}); the "any rule" is stored automatically.

The response is the full read representation of the created record, in which shipping_option is expanded into a nested object.

post
/attribute_based_shipping_options/
Authorizations
AuthorizationstringRequired

Token credential sent in the Authorization header, in the form: Token <your-token>. Requires a staff (admin) account.

Body

Fields for creating an attribute based shipping option.

Unlike the read representation, shipping_option is the identifier of an existing shipping option, not a nested object.

shipping_optionintegerRequired

Identifier of an existing shipping option to link. Must refer to a shipping option that exists.

Example: 4
namestring · max: 128 · nullableRequired

Descriptive name of the record, used to tell apart several records that reuse the same shipping option. Send null to create the record without a name.

Example: Vendor A — Standard
calculatorobjectRequired

Calculator configuration, applied to the shipping cost of a matched item group instead of the linked shipping option's own calculator. The object must contain a slug key identifying the calculator. See the Shipping Rules & Calculators guide for available calculators and their parameters.

Example: {"slug":"fixed-price-calculator","fixed_price":"14.99"}
ruleobjectRequired

Rule configuration, applied instead of the linked shipping option's own rule. The object must contain a slug key identifying the rule. Send {} to apply the "any rule", which makes the option eligible for every item group. See the Shipping Rules & Calculators guide for available rules and their parameters.

Example: {"slug":"product-attribute-rule","name":"Product Attribute Rule","func":"all","attribute_field":"shipping_group","attribute_value":"vendor_a"}
is_activebooleanOptional

Whether the record is active. Inactive records are never evaluated at checkout.

Default: true
sort_orderintegerOptional

Sort order used when evaluating records at checkout. Lower values are evaluated first.

Default: 0
Responses
201

The created attribute based shipping option.

application/json

An attribute based shipping option returned by the API.

pkintegerRead-onlyRequired

Unique identifier of the attribute based shipping option.

namestring · max: 128 · nullableRequired

Descriptive name of the record, used to tell apart several records that reuse the same shipping option.

Example: Vendor A — Standard
is_activebooleanRequired

Whether the record is active. Only active records are evaluated at checkout.

Default: true
calculatorobjectRequired

Calculator configuration. Determines how the shipping cost of a matched item group is computed, overriding the calculator of the linked shipping option.

The object must contain at minimum a slug key identifying the calculator. See the Shipping Rules & Calculators guide for available calculators and their parameters.

Example: {"slug":"amount-based-calculator","amounts":[{"min_amount":"0.00","max_amount":"250.00","shipping_amount":"14.99"},{"min_amount":"250.00","max_amount":null,"shipping_amount":"0.00"}]}
ruleobjectRequired

Rule configuration. Determines which item groups this option is offered for, overriding the rule of the linked shipping option.

The object contains a slug key identifying the rule. Records created with an empty rule are stored with the "any rule", which makes the option eligible for every group.

Example: {"slug":"any-rule","name":"Any Rule"}
sort_orderintegerRequired

Sort order used when evaluating records at checkout. Lower values are evaluated first.

Default: 0
post/attribute_based_shipping_options/
POST /api/v1/remote/1/attribute_based_shipping_options/ HTTP/1.1
Host: sandbox.akinon.com
Authorization: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 303

{
  "shipping_option": 4,
  "name": "Vendor A — Standard",
  "calculator": {
    "slug": "fixed-price-calculator",
    "fixed_price": "14.99"
  },
  "rule": {
    "slug": "product-attribute-rule",
    "name": "Product Attribute Rule",
    "func": "all",
    "attribute_field": "shipping_group",
    "attribute_value": "vendor_a"
  },
  "is_active": true,
  "sort_order": 0
}
{
  "pk": 12,
  "name": "Vendor A — Standard",
  "is_active": true,
  "calculator": {
    "slug": "fixed-price-calculator",
    "fixed_price": "14.99"
  },
  "rule": {
    "slug": "any-rule",
    "name": "Any Rule"
  },
  "sort_order": 0,
  "shipping_option": {
    "pk": 4,
    "name": "Vendor Standard Shipping",
    "slug": "vendor-standard-shipping",
    "is_active": true,
    "sort_order": 0,
    "description": null,
    "kwargs": {
      "required_fields": []
    },
    "delivery_type": {
      "value": "standard",
      "label": "Standard Delivery"
    }
  }
}

Last updated

Was this helpful?