Skip to content

Latest commit

 

History

History
287 lines (257 loc) · 7.24 KB

errors.mdx

File metadata and controls

287 lines (257 loc) · 7.24 KB
title description
Errors
How to handle errors returned from Meadow endpoints

Meadow uses HTTP response codes to indicate the success or failure of an API request. Codes in the 2xx range indicate success. Codes in the 4xx range indicate an error that failed given the information provided (e.g., a required parameter was omitted, a order could not be created, etc.). Codes in the 5xx range indicate an error with Meadow's servers (which should happen very infrequently).

Error Response

When an error is returned, it will be in the following format

A human readable string to describe the error to a developer A code pertaining to a specific Meadow error (Example: `INVALID_API_CREDENTIALS`) Some errors will contain additional information in this object to help debug the issue

Example

{
  "error": {
    "message": "Your API credentials are invalid.",
    "code": "INVALID_API_CREDENTIALS"
  }
}

Error Codes

Below is a list of error codes that Meadow may return on various requests. This list does not contain every single error that is possible, so we encourage you to handle unknown codes that you have not seen before.

INSUFFICIENT_PERMISSIONS

The X-Client-Key is valid but does not have the proper permissions for that endpoint

{
  "error": {
    "message": "This API client key does not have permissions to perform this request.",
    "code": "INSUFFICIENT_PERMISSIONS"
  }
}

INVALID_API_CREDENTIALS

Thrown when either the X-Consumer-Key or X-Client-Key provided is invalid

{
  "error": {
    "message": "Your API credentials are invalid.",
    "code": "INVALID_API_CREDENTIALS"
  }
}

INVALID_CHILD_RESOURCE

Thrown when data submitted is not owned by the parent resource specified (Example: Submitting options that belong to another product)

{
  "error": {
    "message": "That child resource does not belong to the specified parent.",
    "code": "INVALID_CHILD_RESOURCE"
  }
}

INVALID_IDEMPOTENCY_KEY

TheidempotencyKey submitted is not a valid uuid v4. We recommend using the idempotencyKey returned from pricing so you do not run into this error.

{
  "error": {
    "message": "idempotencyKey must be a uuid v4",
    "code": "INVALID_IDEMPOTENCY_KEY"
  }
}

INVALID_INVENTORY_TYPE

A product option ID was or was not passed when it was supposed to. Check the inventoryType of the product. If it is option then productOptionId should be passed, otherwise do not include this ID in the purchase order line item.

{
  "error": {
    "message": "Incorrect inventory type submitted.",
    "code": "INVALID_INVENTORY_TYPE"
  }
}

INVALID_PARAMS

One or more of the properties in the request body is invalid.

{
  "error": {
    "message": "type must be one of: delivery, pickup, in-store.",
    "code": "INVALID_PARAMS"
  }
}

INVALID_ORDER

An order was unable to be created for an unknown reason

{
  "error": {
    "message": "The order you submitted was malformed.",
    "code": "INVALID_ORDER"
  }
}

INVALID_ORDER_QUANTITY

Thrown when a line item has an invalid quantity

{
  "error": {
    "message": "Orders cannot contain negative quantities.",
    "code": "INVALID_ORDER_QUANTITY"
  }
}

INVALID_ORDER_TYPE

Throw when an order type (example: pickup) is submitted but the organization does not allow that type of order

{
  "error": {
    "message": "The organization does not support that order type.",
    "code": "INVALID_ORDER_TYPE"
  }
}

MISSING_PARAMS

The request body is missing a required parameter

{
  "error": {
    "message": "Please enter your address.",
    "code": "MISSING_PARAMS",
    "meta": {
      "missing": [
        "address"
      ]
    }
  }
}

NON_ZERO_INVENTORY

This product has non zero inventory and the product (or option) cannot be deleted. Ask the client organization to zero out the inventory.

{
"error": {
  "message": "This operation may not be performed while a product has inventory.",
  "code": "NON_ZERO_INVENTORY"
}

ORDER_MINIMUM_NOT_MET

Organizations may set minimums for orders. This is thrown if the final total is under the minimum.

{
  "error": {
    "message": "The amount you submitted is under the order minimum for this organization.",
    "code": "ORDER_MINIMUM_NOT_MET",
    "meta": {
      "minimum": "$75"
    }
  }
}

OUT_OF_STOCK

Thrown when there is not enough inventory of a product or product option to create an order

{
  "error": {
    "message": "An order line exceeds current inventory.",
    "code": "OUT_OF_STOCK",
    "meta": {
      "lineItem": {
        "productOptionId": 2307,
        "quantity": 1,
        "specifiedPackageId": null
      },
      "product": {
        "name": "Blue Dream"
      }
    }
  }
}

PRODUCT_CATEGORY_NOT_FOUND

We could not find the category. Please use the product categories API to get a list of valid category names.

{
  "error": {
    "message": "A primary category with that name was not found.",
    "code": "PRODUCT_CATEGORY_NOT_FOUND"
  }
}

PRODUCT_IS_INACTIVE

Thrown when an organization has removed a product from their menu, but an order was submitted with it.

{
  "error": {
    "message": "One of the products you submitted is currently inactive.",
    "code": "PRODUCT_IS_INACTIVE",
    "meta": {
      "productId": 994
    }
  }
}

PURCHASE_LIMIT_EXCEEDED

Each state has its own set of purchase limits. When an order would put a customer over the limit, this error is thrown

{
  "error": {
    "message": "This order is over the daily purchase limit by 3.36g of non-concentrated cannabis (flowers).",
    "code": "PURCHASE_LIMIT_EXCEEDED",
    "meta": {
      "overages": [
        {
          "cannabisType": "non-concentrated",
          "limit": "28.5",
          "total": "31.86",
          "overage": "3.36"
        }
      ]
    }
  }
}

PURCHASE_ORDER_CLOSED

The purchase order status is closed and no more updates can be made. You can ask the organization to reopen from Meadow.

{
  "error": {
    "message": "This purchase order is already closed. You may only set paymentStatus to paid.",
    "code": "PURCHASE_ORDER_CLOSED"
  }
}

PURCHASE_ORDER_LINE_ITEM_RECEIVED

This line item has been received and cannot be edited or deleted.

{
  "error": {
    "message": "Purchase Order Line Items that already have receptions may not be edited.",
    "code": "PURCHASE_ORDER_LINE_ITEM_RECEIVED"
  }
}

PURCHASE_ORDER_MISSING_CUSTOM_DATE

For customer payment terms, paymentTermsDueDate must be submitted.

{
  "error": {
    "message": "Purchase Orders with paymentTerms: Custom must have a paymentTermsDueDate",
    "code": "PURCHASE_ORDER_MISSING_CUSTOM_DATE"
  }
}

TRANSACTION_RETRY_EXCEEDED

This error should be very rare, but if it is thrown, show a generic error to the customer with a button to submit the order again.

{
  "error": {
    "message": "Retry limit exceeded for concurrent transactions. Retry the request.",
    "code": "TRANSACTION_RETRY_EXCEEDED"
  }
}