Skip to content

Start a workflow from Square events

To run a workflow when Square reports a payment, an order, a refund, or a changed customer, add a Webhook block whose Source is Square and give its URL to a webhook subscription of your Square application. Square posts one event per request. Each event starts its own run.

You need a Square application whose webhook subscriptions you can open in the Developer Console, and edit access to the workflow’s project. The Square steps happen in Square’s own console.

Add the Webhook block and generate its URL

Section titled “Add the Webhook block and generate its URL”
  1. In a draft workflow, add a Webhook block. The block palette also lists Square webhook in the Start group, which adds the block with its source already set.
  2. Under Source, choose Square. The line under the setting reads “Verifies the signature · one run per event · skips duplicates”.
  3. Under Webhook URL, select Generate URL, then copy the URL with the copy button beside it.

The badge beside the URL reads “Runs start after publish”. The URL contains a token, and anyone who has the URL can send requests to it. Keep it out of shared documents.

  1. In Square’s Developer Console, select Open on your application.
  2. Under Webhooks, select Subscriptions, then Add subscription.
  3. Enter a name, and paste the URL you copied as the notification URL. Paste it exactly as the block shows it, with nothing added or removed.
  4. Choose an API version and the events Square sends to this URL, and select Save.

Square signs each request over the notification URL as it is entered in the subscription, followed by the request’s body. The check passes only when that URL is the block’s URL, character for character. A subscription whose URL has an added slash, an added query string, or different capital letters delivers to the block, and every delivery is listed as Refused.

The Webhook block offers these Square event types: payment.created, payment.updated, order.created, order.updated, order.fulfillment.updated, refund.created, refund.updated, customer.created, customer.updated, invoice.payment_made, booking.created, and inventory.count.updated.

Square issues a Signature Key for each subscription. It lets OutWin check the signature on each request.

  1. In Square, under Subscriptions, select the subscription’s name to open Endpoint Details.
  2. In the Signature Key box, select Show, and copy the key.
  3. In OutWin, paste it into Signature key in the block’s settings and select Save.

After you save, the settings show only the last four characters of the key, with Replace and Remove. Under Set up, the second line changes to “The signature key is saved: deliveries are verified.”

Square issues the key for one subscription, so OutWin saves it on the block’s URL. It is not saved on a connection. A second Webhook block has its own URL and needs its own Square subscription and key.

Square’s signature carries no time, so OutWin checks none. A saved copy of a signed request that is sent again passes the check. If its event already ran in the last 72 hours, it is listed as Duplicate and starts no run.

Without a saved key the block still starts runs, and nothing is verified: anyone who has the URL can start the workflow. Publishing then shows a warning that ends “has no signing secret saved, so its deliveries are not verified: anyone who has this URL can start this workflow”. The warning does not block publishing.

Under Events that start a run, tick the event types that start a run. With none ticked, every event Square sends starts a run. To start runs for a type that is not listed, type it into the box under the list and select Add.

An event whose type is not ticked is listed as Filtered out and starts no run. To narrow further by a field of the event, add a row under Only when. Webhook settings lists the comparisons.

  1. In Square, cause one of the events the subscription sends, for example with a test payment in an environment that moves no real money.
  2. In OutWin, look under Recent deliveries in the block’s settings.

Recent deliveries lists every event that reached the URL, including while the workflow is a draft. On a draft each event is listed as Dropped with “The workflow is not published, so nothing ran.” It starts no run and is not run later. The last line under Set up changes from “Waiting for the first event…” to, for example, “Received payment.created. Dropped.”

With a key saved, an event listed as Dropped on a draft has passed the signature check. A delivery that fails the check is listed as Refused.

If you have edit access, select an event to see what the block passed on. The list is kept for seven days, and the data of the newest 20 events is kept.

Each run receives one Square event. An HTTP request block or a database block directly after the Webhook block reads it with these expressions. An AI block such as Think receives the whole value as its input.

Expression What it holds
{{input.body}} The event as Square sent it, with the fields type, event_id, and created_at. Other fields depend on the event type.
{{input.body.event_id}} One field of the event. Read any other field the same way.
{{input.event.type}} The event’s type, such as payment.created. It is the event’s type field.
{{input.event.id}} The event’s id. It is the event’s event_id field.
{{input.event.time}} The event’s time as an ISO 8601 date and time. It is read from the event’s created_at field.
{{input.delivery.verified}} true only when the signature was checked and passed.

A block further along reads the same values through the Webhook block’s name, as in {{steps["Square"].body.event_id}} for a block named Square. Data and context describes what each block passes on.

Publish the workflow. From then on, each event that passes the filter starts a run. On a published workflow the block’s settings are read-only, and Recent deliveries is in the block’s inspector. You can still replace the key there.

Outcome What happened
Ran The event started a run.
Waiting 10 runs of the workflow are already active. The event starts a run when one of them ends. An event that waits longer than an hour is listed as Dropped.
Duplicate An event with the same event_id already ran in the last 72 hours. The line reads “This event was already received and run, so it did not run again.”

Runs start in the order events arrive. That is not always the order things happened, so do not build a workflow that relies on payment.created arriving before payment.updated.

Receiving an event costs no credits, and neither does an event that is filtered out or a duplicate. A run that starts uses credits for the blocks that run in it.

Open Recent deliveries and read the outcome and the sentence beside the newest event.

What you see Cause Fix
“Nothing has arrived yet.” No request has reached the URL. Check that the subscription in Square sends the event you caused and that its notification URL is the block’s current URL. Rotate token on a published workflow changes the URL, and the old one stops working.
Dropped with “The workflow is not published, so nothing ran.” The workflow is a draft. Publish the workflow. Events that arrived before then are not run later.
Dropped with “The workflow is paused, so nothing ran.” The workflow is paused. Resume the workflow. Events that arrived while it was paused are not run later.
Filtered out with Events of type "order.updated" are not chosen on this trigger. The event’s type is not ticked under Events that start a run. Tick the type, or clear every tick so that all events start a run. The settings are read-only on a published workflow.
Refused with “The signature did not match. Check that the secret saved here is the one the sender shows for this URL.” Either the saved key is not the Signature Key of this subscription, or the notification URL in Square is not exactly the block’s URL. The first happens when the key was copied from another subscription. The second happens when the URL was typed or edited in Square. Copy the block’s URL again and paste it over the subscription’s notification URL in Square. Then select Show under Endpoint Details, copy the key again, and select Replace. You do not republish the workflow.
Refused with “The request carried no signature.” A key is saved in OutWin, and the request did not carry Square’s signature. A request sent by hand to try the URL has none. Cause the event in Square so that Square sends the request.

A delivery listed as Refused is answered with status 401 and starts nothing. OutWin keeps none of its data. For every other outcome in the table, Square receives a success response and OutWin does not run the event later.