Webhooks

How to set up Webhook subscriptions in Fieldwire

🚧

This document covers an in-development feature and may be subject to change

Intro

Webhooks allow developers to be notified via API when changes occur in your Fieldwire projects. They can facilitate building integrations that respond real-time to changes, rather than checking for updates on a pre-determined cadence. Currently, creating and editing webhook subscriptions must also be done via API and will require providing a callback url. The callback URL is a URL that you own that will be the destination for notifications when updates occur in Fieldwire.

This document describes configuring the webhook subscriptions. For more info on the data returned in the webhook payloads please see https://developers.fieldwire.com/docs/webhook-event-types

Webhook Subscriptions

The webhook subscription is the Fieldwire entity that describes the settings for the notification. See below for details on how to read, create, update and delete webhook subscriptions.

Create Subscription

To create a new subscription send a POST request to the subscriptions endpoint

url = "https://webhook-api.us.fieldwire.com/webhook/account/{{account_id}}/subscriptions"

body = {
  "subscription_name":{{subscription_name}},
  "description": {{description}},
  "post_url": {{post_url}},
  "subscription_status": {{subscription_status}}
}

Field explanations

Field NameDescriptionRequired
subscription_nameName of subscription, max length 50 charactersTRUE
descriptionDescription of subscription, max length 200 charactersTRUE
post_urlURL to post the event data toTRUE
subscription_statusWhether the subscription is active or not. Can either be "enabled" or "disabled"TRUE

Note: all properties are required

Example request (cURL)

curl --location 'https://webhook-api.us.fieldwire.com/webhook/account/<Account ID>/subscriptions' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <access_token>' \
  --data '{
    "subscription_name": "Example Webhook Subscription",
    "description": "This is a demo subscription",
    "post_url": "https://Example.com/test",
    "subscription_status": "enabled"
  }'

Response:

HTTP code 201

{
  "subscription_id": "76b770fe-59c3-47a1-b1fa-b2e529a44a6c",
  "subscription_name": "Example Webhook Subscription",
  "description": "This is a demo subscription",
  "post_url": "https://Example.com/test",
  "subscription_status": "enabled",
  "account_id": 2
}

Update Subscription

To update an existing subscription send a PATCH request to the subscriptions endpoint using your subscription ID

url = "https://webhook-api.us.fieldwire.com/webhook/account/{{account_id}}/subscriptions/{{subscription_id}}"

body = {
  "subscription_name":{{subscription_name}},
  "description": {{description}},
  "post_url": {{post_url}},
  "subscription_status": {{subscription_status}}
}

note: any fields can be updated as needed, see above for field explanations

Example request (cURL)

curl --location --request PATCH 'https://webhook-api.us.fieldwire.com/webhook/account/<Account ID>/subscriptions/<Subscription ID>' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <access_token>' \
  --data '{
    "subscription_name": "Updated Subscription Name"
  }'

Response:

HTTP response code 202

Get All Subscriptions

To see all subscriptions present on the account, make a GET call to the following endpoint

Example request (cURL)

curl --location 'https://webhook-api.us.fieldwire.com/webhook/account/{{account_id}}/subscriptions' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <access_token>'

Response:

HTTP code 200

An array of json objects

[
  {
    "subscription_id": "76b770fe-59c3-47a1-b1fa-b2e529a44a6c",
    "subscription_name": "Example Webhook Subscription",
    "description": "This is a demo subscription",
    "post_url": "https://Example.com/test",
    "subscription_status": "enabled",
    "account_id": <Account Id>
  }
]

Delete Subscription

To delete an existing subscription, send a DELETE request to the subscriptions endpoint using your subscription ID

Example request (cURL)

curl --location --request DELETE 'https://webhook-api.us.fieldwire.com/webhook/account/<account_id>/subscriptions/<subscription_id>' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <access_token>' \

Response

HTTP code 202

Get Single Subscription

To see a single subscription, make a GET call to the following endpoint using your subscription ID

Example request (cURL)

curl --location 'https://webhook-api.us.fieldwire.com/webhook/account/<account_id>/subscriptions/<subscription_id>' \
  --header 'Authorization: Bearer <access_token>'

Response:

{
  "subscription_id": "76b770fe-59c3-47a1-b1fa-b2e529a44a6c",
  "subscription_name": "Example Webhook Subscription",
  "description": "This is a demo subscription",
  "post_url": "https://Example.com/test",
  "subscription_status": "enabled",
  "account_id": <account_id>
}