Core API

Stock API Docs

openapi: 3.0.3 info: title: Sparklayer API Stock contact: email: [email protected] version: 1.0.0 tags:

  • name: Stock description: Covers all stock entities including stock locations and stock levels. paths: /api/v1/batch-fetch-stock: parameters:
    • $ref: '#/components/parameters/Header.SiteId' post: summary: Get stock levels at all connected locations for the provided SKUs operationId: getBatchStock tags:
      • Stock Levels - Bulk operations requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/BatchFetchStock' responses: '200': description: Successful response content: application/json: schema: type: array items: type: object properties: sku: description: Product Variant SKU type: string example: SKU-1 stock_levels: description: Stock levels for the SKU at each location type: array items: $ref: '#/components/schemas/StockLevel' default: $ref: '#/components/responses/Default' /api/v1/batch-update-stock: parameters:
    • $ref: '#/components/parameters/Header.SiteId' post: summary: Batch update stock levels for the provided SKUs operationId: updateBatchStock tags:
      • Stock Levels - Bulk operations requestBody: required: true content: application/json: schema: type: array minItems: 1 items: oneOf: - $ref: '#/components/schemas/BatchUpdateStockLevelByLocationId' - $ref: '#/components/schemas/BatchUpdateStockLevelByExternalLocationId' responses: '204': description: Success - No Content default: $ref: '#/components/responses/Default' /api/v1/batch-delete-stock: parameters:
    • $ref: '#/components/parameters/Header.SiteId' post: summary: Batch delete stock levels for the provided SKUs operationId: deleteBatchStock tags:
      • Stock Levels - Bulk operations requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/SKUs' responses: '204': description: Success - No Content default: $ref: '#/components/responses/Default' /api/v1/stock-locations: get: tags:
      • Stock Locations summary: Get Stock Locations for the site operationId: getStockLocations parameters:
      • $ref: '#/components/parameters/Header.SiteId' responses: '200': description: Successful response (ordered by ID - asc) content: application/json: schema: type: array items: $ref: '#/components/schemas/StockLocation' default: $ref: '#/components/responses/Default' post: tags:
      • Stock Locations summary: Create a Stock Location operationId: createStockLocation parameters:
      • $ref: '#/components/parameters/Header.SiteId' requestBody: content: application/json: schema: $ref: '#/components/schemas/StockLocation' responses: '200': description: Successful response content: application/json: schema: $ref: '#/components/schemas/StockLocation' default: $ref: '#/components/responses/Default' /api/v1/stock-locations/{StockLocationID}: get: tags:
      • Stock Locations summary: Get a Stock Location operationId: getStockLocation parameters:
      • $ref: '#/components/parameters/Path.StockLocationID'
      • $ref: '#/components/parameters/Header.SiteId' responses: '200': description: Successful response content: application/json: schema: $ref: '#/components/schemas/StockLocation' default: $ref: '#/components/responses/Default' patch: tags:
      • Stock Locations summary: Update a Stock Location operationId: updateStockLocation parameters:
      • $ref: '#/components/parameters/Path.StockLocationID'
      • $ref: '#/components/parameters/Header.SiteId' requestBody: content: application/json: schema: $ref: '#/components/schemas/StockLocation' required: true responses: '200': description: Successful response content: application/json: schema: $ref: '#/components/schemas/StockLocation' default: $ref: '#/components/responses/Default' delete: tags:
      • Stock Locations summary: Delete a Stock Location operationId: deleteStockLocation parameters:
      • $ref: '#/components/parameters/Path.StockLocationID'
      • $ref: '#/components/parameters/Header.SiteId' responses: '204': description: Success - No Content default: $ref: '#/components/responses/Default' components: parameters: Path.StockLocationID: name: StockLocationID description: Stock Location ID (internal or external) in: path required: true schema: type: string style: simple Header.SiteId: name: Site-Id description: Spark Layer Site ID in: header required: true schema: type: string example: jones-climbing schemas: SKUs: type: object properties: skus: type: array items: type: string example: SKU-1 BatchFetchStock: type: object properties: skus: type: array items: type: string example: SKU-1 filter: type: object properties: stock_location_ids: type: array items: type: string format: uuid example: 123e4567-e89b-12d3-a456-426614174000 all_stock_locations: type: boolean StockLocationId: type: object properties: stock_location_id: description: Stock Location ID (internal UUID) type: string format: uuid example: 123e4567-e89b-12d3-a456-426614174000 StockLocationName: type: object properties: stock_location_name: description: Stock Location Name type: string example: Main Warehouse BaseStockLevel: type: object properties: stock_level: description: Quantity of stock held at the location type: integer format: int32 default: 0 example: 9 restock_date: description: Restock Date type: string format: date nullable: true example: '2020-01-01' min_stock_level: description: Allow pre-ordering / overselling up to this qty. For example, if set to -9 and stock level was 0, 9 units could be sold. type: integer format: int32 default: 0 example: -9 created_at: type: string format: date-time readOnly: true updated_at: type: string format: date-time readOnly: true StockLevel: type: object allOf:
      • $ref: '#/components/schemas/BaseStockLevel'
      • $ref: '#/components/schemas/StockLocationId'
      • $ref: '#/components/schemas/StockLocationName' BatchUpdateStockLevelByLocationId: type: object additionalProperties: false allOf:
      • $ref: '#/components/schemas/StockLocationId'
      • type: object properties: sku: description: Product Variant SKU type: string maxLength: 100 required:
        • stock_location_id
        • sku
        • stock_level
      • $ref: '#/components/schemas/BaseStockLevel' BatchUpdateStockLevelByExternalLocationId: type: object additionalProperties: false allOf:
      • type: object properties: stock_location_external_id: description: External ID (must be unique for the site) maxLength: 255 type: string example: warehouse-1 sku: description: Product Variant SKU type: string maxLength: 100 required:
        • stock_location_external_id
        • sku
        • stock_level
      • $ref: '#/components/schemas/BaseStockLevel' StockLocation: type: object additionalProperties: false required:
      • name
      • external_id properties: id: description: SparkLayer site Stock Location ID type: string format: uuid readOnly: true example: 123e4567-e89b-12d3-a456-426614174000 name: description: Name maxLength: 255 type: string example: Stock Warehouse 1 external_id: description: External ID (must be unique for the site) maxLength: 255 type: string example: warehouse-1 created_at: type: string format: date-time readOnly: true updated_at: type: string format: date-time readOnly: true responses: Default: description: Error Response content: application/problem+json: schema: title: Error Message Response description: Structure for returning RFC-7807 errors from API type: object additionalProperties: false properties: detail: description: Human-readable summary of the error type: string example: Data Validation Failed status: description: HTTP Status code returned from API type: integer example: 400 title: description: Machine-readable error code type: string example: invalid-api-request-contents type: type: string example: https://docs.sparklayer.io/api/errors#invalid-api-request-contents nullable: true errors: description: A list of errors related to the call type: array nullable: true items: type: object properties: code: type: string description: Machine-readable error code example: resource-not-found property: type: string description: The property the error relates to example: stock_location_id message: type: string description: Human readable summary of the error example: stock_location_id not found Empty: description: Empty Response