Creating a Zapier publish invoice webhook receiving error

After following the directions in your Developer Invoice Publish documentation I am receiving a Bad request. (HTTP Status Code: 400)

I am also confused as there are two uids below. Are these supposed to be left alone as default or do they correspond to the order id and invoice id? if so, which one is which?
Second, am I required to have everything below to publish or is there a minimum?

And finally, are dates supposed to be formatted in a specific manner or is 2024-05-07 acceptable?

URL POST:
https://connect.squareup.com/v2/invoices/0-ChBMLI5zIMOOYVCQtJ6HsuGhEPoN/publish

{
“version”: 1,
“location_id”: “LJNVC96B0Z4M4”,
“order_id”: “CAISENgvlJ6jLWAzERDzjyHVybY”,
“payment_requests”: [
{
“uid”: “2da7964f-f3d2-4f43-81e8-5aa220bf3355”,
“request_type”: “BALANCE”,
“due_date”: “{{238616178__Date_ISO8601}}”,
“tipping_enabled”: false,
“reminders”: [
{
“uid”: “beebd363-e47f-4075-8785-c235aaa7df11”,
“relative_scheduled_days”: -1,
“message”: “Your invoice is due prior to scheduling QA”,
“status”: “PENDING”
}
],
“computed_amount_money”: {
“amount”: 15000,
“currency”: “USD”
},
“total_completed_amount_money”: {
“amount”: 0,
“currency”: “USD”
},
“automatic_payment_source”: “NONE”
}
],
“invoice_number”: “{{_GEN_1715056892428__invoice number}}”,
“title”: “Set Up Fee”,
“description”: “One time setup free to access webinar materials!”,
“scheduled_at”: “2030-01-13T10:00:00Z”,
“status”: “SCHEDULED”,
“timezone”: “America/Los_Angeles”,
“created_at”: “{{_GEN_1715056892430__invoice__created_at}}”,
“updated_at”: “{{_GEN_1715056892430__invoice__updated_at}}”,
“primary_recipient”: {
“customer_id”: “{{_GEN_1714979117595__id}}”,
“given_name”: “{{_GEN_1714979117595__given_name}}”,
“family_name”: “{{_GEN_1714979117595__family_name}}”,
“email_address”: “{{_GEN_1714979117595__email_address}}”,
“phone_number”: “{{238616178__PhoneNumber}}”
},
“public_url”: “Square}”,
“accepted_payment_methods”: {
“card”: true,
“square_gift_card”: false,
“bank_account”: false,
“buy_now_pay_later”: false,
“cash_app_pay”: false
},
“custom_fields”: [
{
“label”: “Event Reference Number”,
“value”: “Ref. #{{_GEN_1715056892428__invoice number}}”,
“placement”: “ABOVE_LINE_ITEMS”
},
{
“label”: “Terms of Service”,
“value”: “The terms of service are…”,
“placement”: “BELOW_LINE_ITEMS”
}
],
“delivery_method”: “EMAIL”,
“sale_or_service_date”: “{{238616178__Date1_ISO8601}}”,
“store_payment_method_enabled”: false
}
}

Where did that order_id come from? I’m not seeing that order in our system. :slightly_smiling_face:

From when I created the order and then created the draft invoice successfully. Now it just asked me for customer ID when that’s not the requirement.

Every invoice is required to have a primary recipient. Whether it be a customer_id or the information is entered into the invoice at the time of creation. :slightly_smiling_face:

Documentation doesn’t require it. It is present in CREATE in draft.

In API explorer, there is no place to add customer ID

A primary recipient is required in order to publish an invoice. :slightly_smiling_face:

Where do you put the primary recipient in API Explorer for Publish? It was already entered in for Create, but for some reason never passed on, (the invoice exists) but I don’t see an option in the body in API explore to add the recipient for Publish.

You’ll need to first UpdateInvoice with the primary recipient then publish once updated. :slightly_smiling_face:

How do I update an invoice that has not been published? The whole point is to publish the draft of the invoice…

I redid create order, create draft, and tried to publish again but still get errors. The draft was created for the customer and it shows up as a draft in square invoices.

I still get BAD error for publish. Here is my information, can you review it? Thanks.

Create Order App ID: sq0idp-2EZWnJ3hLwRp98SOm75jsQ idempotency_key ho3k8ri30km

Create Draft Invoice App ID: sq0idp-wZvlJDU3HFDEoJHwX82Lww idempotency_key key 9aa3q16k49t
Draft Invoice Id inv:0-ChCyk-8IggXUVJTXkcRfftu6EPoN

Publish Invoice App ID: sq0idp-JEUzjZDmwgMGw4eBJyh9uw idempotency_key key 2sla8aak3ar

Version 0

Taking a look but is there a reason you have an app ID for each step? Ideally you should just have one AppID for every step in creating and publishing an Invoice. :slightly_smiling_face:

Looks like the reason that this is failing is because the JSON in the API request is malformed. It needs to be:

{
  "version": 0,
  "idempotency_key": "2sla8aak3ar"
}

The team is looking to add better error messaging for this. :slightly_smiling_face:

Rookie mistake. Thanks for pointing that out, it now works.

Is it true that the API can no longer interact with Invoice Templates?

That’s correct, invoice templets aren’t currently supported with our APIs. :slightly_smiling_face: