> ## Documentation Index
> Fetch the complete documentation index at: https://sendcloud.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a shipping rule

> Create a shipping rule that applies its actions to a shipment whenever the shipment matches its conditions.



## OpenAPI

````yaml /.openapi/v3/shipping-rules/openapi.yaml post /shipping-rules/rules
openapi: 3.1.0
info:
  title: Shipping Rules [BETA]
  version: 3.0.0
  description: >-
    The Sendcloud Shipping Rules API lets you automate how shipments are
    handled. A shipping rule applies one or more actions to a shipment whenever
    the shipment matches the rule's conditions, so you can set shipping methods,
    add insurance, or update other properties without manual work.
  contact:
    name: Sendcloud API Support
    url: https://www.sendcloud.dev
    email: contact@sendcloud.com
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
servers:
  - url: https://panel.sendcloud.sc/api/v3
    description: Sendcloud Production
security: []
tags:
  - name: Rules
    description: Create and manage the shipping rules that are applied to your shipments.
  - name: Possibilities
    description: >-
      Look up the properties, operators, and actions available to build shipping
      rules.
paths:
  /shipping-rules/rules:
    post:
      tags:
        - Rules
      summary: Create a shipping rule
      description: >-
        Create a shipping rule that applies its actions to a shipment whenever
        the shipment matches its conditions.
      operationId: sc-public-v3-shipping-rules-create-rule
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RuleCreate'
            examples:
              InsureHighValueOrders:
                summary: Insure orders of €200 or more
                value:
                  name: Insure high-value orders
                  is_active: true
                  criteria:
                    is_and: true
                    conditions:
                      - property: order_value
                        operator: ge
                        compare_to: '200'
                  actions:
                    - identifier: insurance_pc
                      value: '100'
              CashOnDeliveryForSpain:
                summary: Cash on delivery for Spain
                value:
                  name: Cash on delivery — Spain
                  is_active: true
                  criteria:
                    is_and: true
                    conditions:
                      - property: shipping_country
                        operator: eq
                        compare_to: ES
                  actions:
                    - identifier: set_cod
                      value: 'true'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RuleDetail'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - HTTPBasicAuth: []
        - OAuth2ClientCreds: []
components:
  schemas:
    RuleCreate:
      title: RuleCreate
      type: object
      description: Payload to create a shipping rule.
      properties:
        name:
          type: string
          maxLength: 100
          description: Name of the rule.
          example: Insure high-value parcels
        is_active:
          type: boolean
          default: true
          description: Whether the rule should evaluate against shipments after creation.
        criteria:
          allOf:
            - $ref: '#/components/schemas/RuleCriteriaInput'
          description: Conditions that determine when the rule's actions are applied.
        actions:
          type: array
          description: Actions performed on a shipment when the criteria match.
          items:
            $ref: '#/components/schemas/RuleActionInput'
      required:
        - name
        - criteria
        - actions
    RuleDetail:
      title: RuleDetail
      type: object
      description: A shipping rule including its conditions and actions.
      properties:
        id:
          type: integer
          description: ID of the rule.
          example: 1
        name:
          type: string
          description: Name of the rule.
          example: Insure high-value parcels
        is_active:
          type: boolean
          description: Whether the rule is currently evaluating shipments.
          example: true
        is_invalid:
          type: boolean
          description: >-
            True when the rule cannot be evaluated (e.g. references an
            unavailable property or action).
          example: false
        order:
          type:
            - integer
            - 'null'
          description: >-
            Position in the organization's evaluation order; lower values are
            evaluated first.
          example: 1
        updated_at:
          type:
            - string
            - 'null'
          format: date-time
          description: Timestamp of the last update to the rule.
          example: '2026-06-26T10:15:00Z'
        criteria:
          oneOf:
            - $ref: '#/components/schemas/RuleCriteriaDetail'
            - type: 'null'
          description: Criteria that determine when this rule fires.
        actions:
          type: array
          description: Actions executed when the rule fires.
          items:
            $ref: '#/components/schemas/RuleActionDetail'
      required:
        - id
        - name
        - is_active
        - is_invalid
    ErrorResponse:
      title: ErrorResponse
      type: object
      description: A standardized format for errors in JSON:API responses.
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/ErrorObject'
      required:
        - errors
    RuleCriteriaInput:
      title: RuleCriteriaInput
      type: object
      description: The set of conditions that decide when a rule fires.
      properties:
        is_and:
          type: boolean
          default: true
          description: >-
            If true, all conditions must match (AND); if false, any condition
            matching is enough (OR).
        conditions:
          type: array
          description: Conditions combined by `is_and` to decide whether the rule fires.
          items:
            $ref: '#/components/schemas/RuleConditionInput'
      required:
        - conditions
    RuleActionInput:
      title: RuleActionInput
      type: object
      description: An action to perform when a rule's criteria match.
      properties:
        identifier:
          type: string
          description: >-
            Action identifier (e.g. "set_shipping_method") describing what to do
            when the rule matches.
          example: set_insurance
        value:
          type:
            - string
            - 'null'
          description: >-
            Optional value for the action; required by actions that take a
            parameter.
          example: '500'
      required:
        - identifier
    RuleCriteriaDetail:
      title: RuleCriteriaDetail
      type: object
      description: A set of conditions combined with a boolean operator.
      properties:
        is_and:
          type: boolean
          description: >-
            True when all conditions must match; false when any single condition
            is sufficient.
          example: true
        conditions:
          type: array
          description: Conditions belonging to this criteria block.
          items:
            $ref: '#/components/schemas/RuleConditionDetail'
      required:
        - is_and
    RuleActionDetail:
      title: RuleActionDetail
      type: object
      description: An action stored on a shipping rule.
      properties:
        identifier:
          type: string
          description: Action identifier describing the action type.
          example: set_insurance
        value:
          type:
            - string
            - 'null'
          description: Action parameter value; null when the action has no parameter.
          example: '500'
      required:
        - identifier
    ErrorObject:
      title: Error
      type: object
      description: Error in a JSON:API error format
      properties:
        id:
          type: string
          description: A unique identifier for the error.
        links:
          type: object
          description: >-
            A set of hyperlinks that provide additional information about the
            error.
          properties:
            about:
              type: string
              description: A URL that provides additional information about the error.
        status:
          type: string
          format: int32
          description: The HTTP status code of the error.
          minLength: 1
        code:
          type: string
          description: A unique error code for the error, in snake case format.
          minLength: 1
          enum:
            - unknown_field
            - invalid
            - forbidden
            - invalid_choice
            - min_value
            - 'null'
            - not_found
            - required
            - not_a_list
            - non_field_errors
            - authentication_failed
            - validation_error
            - parcel_announcement_error
        title:
          type: string
          description: A short, human-readable summary of the error.
          minLength: 1
        detail:
          type: string
          description: A human-readable explanation of the error.
          minLength: 1
        source:
          type: object
          description: >-
            An object that identifies the source of the error within the request
            payload.
          properties:
            pointer:
              type: string
              description: >-
                A `JSON` pointer to the location of the error within the request
                payload.
            parameter:
              type: string
              description: The name of the `query` parameter that caused the error.
            header:
              type: string
              description: The name of the `header` parameter that caused the error.
        meta:
          type: object
          description: Additional metadata about the error.
    RuleConditionInput:
      title: RuleConditionInput
      type: object
      description: A single condition to evaluate against a shipment.
      properties:
        property:
          type: string
          description: >-
            Property identifier evaluated against the shipment (e.g. "weight",
            "destination_country").
          example: total_order_value
        operator:
          type: string
          description: >-
            Operator identifier used to compare the property to `compare_to`
            (e.g. "greater_than", "equals").
          example: greater_than
        compare_to:
          type:
            - string
            - 'null'
          description: >-
            Value the property is compared against; must be null for unary
            operators.
          example: '100'
      required:
        - property
        - operator
    RuleConditionDetail:
      title: RuleConditionDetail
      type: object
      description: A single condition that compares a property to a value.
      properties:
        property:
          type: string
          description: Property identifier evaluated by this condition.
          example: total_order_value
        operator:
          type: string
          description: Operator identifier used by this condition.
          example: greater_than
        compare_to:
          type:
            - string
            - 'null'
          description: Compared value; null for unary operators.
          example: '100'
      required:
        - property
        - operator
  securitySchemes:
    HTTPBasicAuth:
      type: http
      description: >-
        Basic Authentication using API key and secrets is currently the main
        authentication mechanism.
      scheme: basic
    OAuth2ClientCreds:
      type: oauth2
      description: >-
        OAuth2 is a standardized protocol for authorization that allows users to
        share their private resources stored on one site with another site
        without having to provide their credentials. OAuth2 Client Credentials
        Grant workflow. This workflow is typically used for server-to-server
        interactions that require authorization to access specific resources.
      flows:
        clientCredentials:
          tokenUrl: https://account.sendcloud.com/oauth2/token/
          scopes:
            api: Default OAuth scope required to access Sendcloud API.

````