Unable to create a new discount catalog object

I’m using the API Explorer to create a new discount catalog object. Since it’s new, the docs say I should enter a # in the id field. However I’m getting an error saying that’s not valid. Is this just a bug within the explorer or is there another way I’m supposed to create a new discount? Leaving the id blank also results in an error saying the field can’t be blank.

curl https://connect.squareup.com/v2/catalog/object \
  -X POST \
  -H 'Square-Version: 2024-12-18' \
  -H 'Authorization: Bearer ' \
  -H 'Content-Type: application/json' \
  -d '{
    "idempotency_key": "47360dee-757d-463d-8536-6d786519529d",
    "object": {
      "type": "DISCOUNT",
      "id": "#",
      "discount_data": {
        "discount_type": "FIXED_AMOUNT",
        "amount_money": {
          "amount": 1000,
          "currency": "USD"
        },
        "modify_tax_basis": "MODIFY_TAX_BASIS"
      }
    }
  }'
{
  "errors": [
    {
      "category": "INVALID_REQUEST_ERROR",
      "code": "INVALID_VALUE",
      "detail": "Object ID must be blank, start with '#', or match an existing object: ID=\"#\".",
      "field": "id"
    }
  ]
}

:wave: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Create Bundled Discounts
Catalog API
Design a Catalog

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

Update: I also tried this in Postman and got the same error

Turns out I misunderstood the docs. The id has to be a value that starts with #, but not only #. like #123

The # symbol is used as a placeholder for a temporary ID when creating a new catalog object. However, it should not be used alone. It should be followed by a unique string to represent the temporary ID of the object being created. For example, you could use #new_discount as the ID when creating a new discount. This temporary ID will be replaced by a permanent ID generated by Square once the object is successfully created.

This answer was reviewed by @Bryan-Square.

Glad to hear that you figured it out. :slight_smile: