Spree Commerce Adjustments API

The Adjustments API from Spree Commerce — 2 operation(s) for adjustments.

OpenAPI Specification

spree-adjustments-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: Admin Account / Address Adjustments API
  contact:
    name: Spree Commerce
    url: https://spreecommerce.org
    email: hello@spreecommerce.org
  description: "Spree Admin API v3 - Administrative API for managing products, orders, and store settings.\n\n## Authentication\n\nThe Admin API requires a secret API key passed in the `x-spree-api-key` header.\nSecret API keys can be generated in the Spree admin dashboard.\n\n## Response Format\n\nAll responses are JSON. List endpoints return paginated responses with `data` and `meta` keys.\nSingle resource endpoints return a flat JSON object.\n\n## Resource IDs\n\nEvery resource is identified by an opaque string ID (e.g. `prod_86Rf07xd4z`,\n`variant_k5nR8xLq`, `or_UkLWZg9DAJ`). Use these IDs everywhere — URL paths,\nrequest bodies, and Ransack filters all accept them directly.\n\n## Error Handling\n\nErrors return a consistent format:\n```json\n{\n  \"error\": {\n    \"code\": \"validation_error\",\n    \"message\": \"Validation failed\",\n    \"details\": { \"name\": [\"can't be blank\"] }\n  }\n}\n```\n"
  version: v3
servers:
- url: http://{defaultHost}
  variables:
    defaultHost:
      default: localhost:3000
tags:
- name: Adjustments
paths:
  /api/v2/platform/adjustments:
    get:
      summary: Return a list of Adjustments
      tags:
      - Adjustments
      security:
      - bearer_auth: []
      description: Returns a list of Adjustments
      operationId: adjustments-list
      parameters:
      - name: page
        in: query
        example: 1
        schema:
          type: integer
      - name: per_page
        in: query
        example: 50
        schema:
          type: integer
      - name: include
        in: query
        description: 'Select which associated resources you would like to fetch, see: <a href="https://jsonapi.org/format/#fetching-includes">https://jsonapi.org/format/#fetching-includes</a>'
        example: order,adjustable
        schema:
          type: string
      - name: filter[order_id]
        in: query
        description: ''
        example: '1234'
        schema:
          type: string
      responses:
        '200':
          description: Records returned
          content:
            application/vnd.api+json:
              examples:
                Example:
                  value:
                    data:
                    - id: '1'
                      type: adjustment
                      attributes:
                        source_type: Spree::TaxRate
                        adjustable_type: Spree::Order
                        amount: '100.0'
                        label: Shipping
                        mandatory: null
                        eligible: true
                        created_at: '2022-11-08T19:33:53.732Z'
                        updated_at: '2022-11-08T19:33:53.732Z'
                        state: open
                        included: false
                        display_amount: $100.00
                      relationships:
                        order:
                          data:
                            id: '1'
                            type: order
                        adjustable:
                          data:
                            id: '2'
                            type: order
                        source:
                          data:
                            id: '1'
                            type: tax_rate
                    - id: '2'
                      type: adjustment
                      attributes:
                        source_type: Spree::TaxRate
                        adjustable_type: Spree::Order
                        amount: '100.0'
                        label: Shipping
                        mandatory: null
                        eligible: true
                        created_at: '2022-11-08T19:33:53.754Z'
                        updated_at: '2022-11-08T19:33:53.754Z'
                        state: open
                        included: false
                        display_amount: $100.00
                      relationships:
                        order:
                          data:
                            id: '1'
                            type: order
                        adjustable:
                          data:
                            id: '3'
                            type: order
                        source:
                          data:
                            id: '2'
                            type: tax_rate
                    meta:
                      count: 2
                      total_count: 2
                      total_pages: 1
                    links:
                      self: http://www.example.com/api/v2/platform/adjustments?page=1&per_page=&include=&filter[order_id]=
                      next: http://www.example.com/api/v2/platform/adjustments?filter%5Border_id%5D=&include=&page=1&per_page=
                      prev: http://www.example.com/api/v2/platform/adjustments?filter%5Border_id%5D=&include=&page=1&per_page=
                      last: http://www.example.com/api/v2/platform/adjustments?filter%5Border_id%5D=&include=&page=1&per_page=
                      first: http://www.example.com/api/v2/platform/adjustments?filter%5Border_id%5D=&include=&page=1&per_page=
              schema:
                $ref: '#/components/schemas/resources_list'
        '401':
          description: Authentication Failed
          content:
            application/vnd.api+json:
              examples:
                Example:
                  value:
                    error: The access token is invalid
              schema:
                $ref: '#/components/schemas/error'
    post:
      summary: Create an Adjustment
      tags:
      - Adjustments
      security:
      - bearer_auth: []
      description: Creates an Adjustment
      operationId: create-adjustment
      parameters:
      - name: include
        in: query
        description: 'Select which associated resources you would like to fetch, see: <a href="https://jsonapi.org/format/#fetching-includes">https://jsonapi.org/format/#fetching-includes</a>'
        example: order,adjustable
        schema:
          type: string
      responses:
        '201':
          description: Record created
          content:
            application/vnd.api+json:
              examples:
                Example:
                  value:
                    data:
                      id: '5'
                      type: adjustment
                      attributes:
                        source_type: Spree::TaxRate
                        adjustable_type: Spree::LineItem
                        amount: '100.0'
                        label: Shipping
                        mandatory: null
                        eligible: true
                        created_at: '2022-11-08T19:33:54.527Z'
                        updated_at: '2022-11-08T19:33:54.527Z'
                        state: open
                        included: false
                        display_amount: $100.00
                      relationships:
                        order:
                          data:
                            id: '7'
                            type: order
                        adjustable:
                          data:
                            id: '1'
                            type: line_item
                        source:
                          data: null
              schema:
                $ref: '#/components/schemas/resource'
        '422':
          description: Invalid request
          content:
            application/vnd.api+json:
              examples:
                Example:
                  value:
                    error: Adjustable can't be blank, Order can't be blank, Label can't be blank, and Amount is not a number
                    errors:
                      adjustable:
                      - can't be blank
                      order:
                      - can't be blank
                      label:
                      - can't be blank
                      amount:
                      - is not a number
              schema:
                $ref: '#/components/schemas/validation_errors'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/create_adjustment_params'
  /api/v2/platform/adjustments/{id}:
    get:
      summary: Return an Adjustment
      tags:
      - Adjustments
      security:
      - bearer_auth: []
      description: Returns an Adjustment
      operationId: show-adjustment
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      - name: include
        in: query
        description: 'Select which associated resources you would like to fetch, see: <a href="https://jsonapi.org/format/#fetching-includes">https://jsonapi.org/format/#fetching-includes</a>'
        example: order,adjustable
        schema:
          type: string
      responses:
        '200':
          description: Record found
          content:
            application/vnd.api+json:
              examples:
                Example:
                  value:
                    data:
                      id: '6'
                      type: adjustment
                      attributes:
                        source_type: Spree::TaxRate
                        adjustable_type: Spree::LineItem
                        amount: '1.0'
                        label: Shipping
                        mandatory: null
                        eligible: true
                        created_at: '2022-11-08T19:33:54.871Z'
                        updated_at: '2022-11-08T19:33:54.875Z'
                        state: open
                        included: false
                        display_amount: $1.00
                      relationships:
                        order:
                          data:
                            id: '8'
                            type: order
                        adjustable:
                          data:
                            id: '2'
                            type: line_item
                        source:
                          data:
                            id: '5'
                            type: tax_rate
              schema:
                $ref: '#/components/schemas/resource'
        '404':
          description: Record not found
          content:
            application/vnd.api+json:
              examples:
                Example:
                  value:
                    error: The resource you were looking for could not be found.
              schema:
                $ref: '#/components/schemas/error'
        '401':
          description: Authentication Failed
          content:
            application/vnd.api+json:
              examples:
                Example:
                  value:
                    error: The access token is invalid
              schema:
                $ref: '#/components/schemas/error'
    patch:
      summary: Update an Adjustment
      tags:
      - Adjustments
      security:
      - bearer_auth: []
      description: Updates an Adjustment
      operationId: update-adjustment
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      - name: include
        in: query
        description: 'Select which associated resources you would like to fetch, see: <a href="https://jsonapi.org/format/#fetching-includes">https://jsonapi.org/format/#fetching-includes</a>'
        example: order,adjustable
        schema:
          type: string
      responses:
        '200':
          description: Record updated
          content:
            application/vnd.api+json:
              examples:
                Example:
                  value:
                    data:
                      id: '8'
                      type: adjustment
                      attributes:
                        source_type: Spree::TaxRate
                        adjustable_type: Spree::LineItem
                        amount: '15.0'
                        label: New label
                        mandatory: null
                        eligible: true
                        created_at: '2022-11-08T19:33:55.540Z'
                        updated_at: '2022-11-08T19:33:55.775Z'
                        state: open
                        included: false
                        display_amount: $15.00
                      relationships:
                        order:
                          data:
                            id: '10'
                            type: order
                        adjustable:
                          data:
                            id: '4'
                            type: line_item
                        source:
                          data:
                            id: '7'
                            type: tax_rate
              schema:
                $ref: '#/components/schemas/resource'
        '422':
          description: Invalid request
          content:
            application/vnd.api+json:
              examples:
                Example:
                  value:
                    error: Label can't be blank
                    errors:
                      label:
                      - can't be blank
              schema:
                $ref: '#/components/schemas/validation_errors'
        '404':
          description: Record not found
          content:
            application/vnd.api+json:
              examples:
                Example:
                  value:
                    error: The resource you were looking for could not be found.
              schema:
                $ref: '#/components/schemas/error'
        '401':
          description: Authentication Failed
          content:
            application/vnd.api+json:
              examples:
                Example:
                  value:
                    error: The access token is invalid
              schema:
                $ref: '#/components/schemas/error'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/update_adjustment_params'
    delete:
      summary: Delete an Adjustment
      tags:
      - Adjustments
      security:
      - bearer_auth: []
      description: Deletes an Adjustment
      operationId: delete-adjustment
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        '204':
          description: Record deleted
        '404':
          description: Record not found
          content:
            application/vnd.api+json:
              examples:
                Example:
                  value:
                    error: The resource you were looking for could not be found.
              schema:
                $ref: '#/components/schemas/error'
        '401':
          description: Authentication Failed
          content:
            application/vnd.api+json:
              examples:
                Example:
                  value:
                    error: The access token is invalid
              schema:
                $ref: '#/components/schemas/error'
components:
  schemas:
    resource_properties:
      type: object
      properties:
        id:
          type: string
        type:
          type: string
        attributes:
          type: object
        relationships:
          type: object
      required:
      - id
      - type
      - attributes
      x-internal: false
    error:
      type: object
      properties:
        error:
          type: string
      required:
      - error
      x-internal: false
    create_adjustment_params:
      type: object
      properties:
        adjustment:
          type: object
          required:
          - order_id
          - label
          - adjustable_id
          - adjustable_type
          properties:
            order_id:
              type: string
            label:
              type: string
              example: Shipping costs
            adjustable_id:
              type: string
            adjustable_type:
              type: string
              example: Spree::LineItem
            source_id:
              type: string
            source_type:
              type: string
              example: Spree::TaxRate
            amount:
              type: number
              example: 10.9
            mandatory:
              type: boolean
            eligible:
              type: boolean
            state:
              type: string
              example: closed
              default: open
              enum:
              - closed
              - open
            included:
              type: boolean
              example: true
              default: false
      required:
      - adjustment
      x-internal: false
    resources_list:
      type: object
      properties:
        data:
          type: array
          items:
            allOf:
            - $ref: '#/components/schemas/resource_properties'
        meta:
          type: object
          properties:
            count:
              type: integer
            total_count:
              type: integer
            total_pages:
              type: integer
          required:
          - count
          - total_count
          - total_pages
        links:
          type: object
          properties:
            self:
              type: string
            next:
              type: string
            prev:
              type: string
            last:
              type: string
            first:
              type: string
          required:
          - self
          - next
          - prev
          - last
          - first
      required:
      - data
      - meta
      - links
      x-internal: false
    update_adjustment_params:
      type: object
      properties:
        adjustment:
          type: object
          properties:
            order_id:
              type: string
            label:
              type: string
              example: Shipping costs
            adjustable_id:
              type: string
            adjustable_type:
              type: string
              example: Spree::LineItem
            source_id:
              type: string
            source_type:
              type: string
              example: Spree::TaxRate
            amount:
              type: number
              example: 10.9
            mandatory:
              type: boolean
            eligible:
              type: boolean
            state:
              type: string
              example: closed
              default: open
              enum:
              - closed
              - open
            included:
              type: boolean
              example: true
              default: false
      required:
      - adjustment
      x-internal: false
    resource:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/resource_properties'
      required:
      - data
      x-internal: false
    validation_errors:
      type: object
      properties:
        error:
          type: string
        errors:
          type: object
      required:
      - error
      - errors
      x-internal: false
  securitySchemes:
    api_key:
      type: apiKey
      name: x-spree-api-key
      in: header
      description: Secret API key for admin access
    bearer_auth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT token for admin user authentication
x-tagGroups:
- name: Authentication
  tags:
  - Authentication
- name: Products & Catalog
  tags:
  - Products
  - Variants
  - Option Types
  - Custom Fields
  - Channels
- name: Pricing
  tags:
  - Pricing
  - Markets
- name: Orders & Fulfillment
  tags:
  - Orders
  - Payments
  - Fulfillments
  - Refunds
- name: Customers
  tags:
  - Customers
  - Customer Groups
- name: Promotions & Gift Cards
  tags:
  - Promotions
  - Gift Cards
- name: Data
  tags:
  - Exports
- name: Configuration
  tags:
  - Settings
  - Stock Locations
  - Payment Methods
  - Staff
  - API Keys
  - Allowed Origins
  - Webhooks