All pages
Powered by GitBook
1 of 10

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Core API spotlights

Introduction

Our full core API and associated documentation is available as a Postman collection - please see our Core API page for details. In this section we spotlight some common API functionality, including step-by-step tutorials.

Pages in this section

Initialising a process flow & sending data via the Patchworks API

Introduction

This section walks through the steps required to pass data from your own system into a Patchworks process flow, via the Patchworks API.

Assumptions

To complete these steps it's assumed that you have:

  • and have a username and password to access your Patchworks dashboard

  • that you want to update via the Patchworks API

What you need to do

The required steps are detailed in the following stages:

Stage #
Action
Tool

In this guide we're using Postman for API calls - you can use your preferred tool for these steps.

Initialising a process flow & sending data via the Patchworks API
Working with cross-reference lookup API requests

Postman

5

Postman

1

Prepare your data

Your preferred text editor

2

Map your payload data

Patchworks dashboard (process flows)

3

Obtain the process flow ID & version for API requests

Patchworks dashboard (process flows)

Registered for a Patchworks account
Built at least one process flow

4

Obtain a token for Patchworks API authentication
Initialise a process flow and send data via the Patchworks API

The steps

Mapping payload data

Introduction

If your process flow is sending source data into a target connection, you should map this data using the map shape. This is done in the usual way with two points to note:

  • No source details are set

Source endpoint

In a typical situation, the is used to map data from a source connection to a target connection. However in this scenario, we don't have a source connection - Patchworks doesn't know what data you are sending in or what system it's coming from.

As such, you won't select any source details when configuring the map shape - just leave these field blank:

Add mapping rules manually

Because Patchworks has no way of knowing the structure of your incoming data, mapping rules must be added manually.

For further guidance please see our page.

Mapping rows must be added manually
map shape
Working with field mappings

Obtaining process flow & version IDs for API requests

Introduction

When you send a Patchworks API request to initialise a process flow, you must provide the internal IDs for the required process flow and version. This guide walks through the steps required to obtain this information.

The steps

Step 1 Log in to the Patchworks dashboard.

Step 2 Select process flows from the left-hand navigation menu and select the process flow that you want to update.

Step 3 Check the title bar in the top-left corner and make a note of the number above the title - this is the process flow ID:

Step 4 Click the settings icon:

...to access process flow settings:

Step 5 Look in the versions panel and find the version of this process flow that you want to initialise, then note the associated ID - this is the process flow version ID:

For more information about process flow versioning please see our page.

Step 6 You'll use this information in any API requests made to initialise this process flow.

Preparing your data

Introduction

The Patchworks inbound API supports data within strings. This data must be passed within a payload key.

Required format

The required data format is a JSON object with a payload key containing a string of data. For example:

Non-strings and raw payloads are not currently supported.

Here, note that the payload key is in a JSON object, and is being used to hold different types of data as strings - text, XML and JSON.

Quickstart guide

Introduction

All steps required to initialise a process flow via the are detailed . This page provides a quick overview of these steps.

Summary

Process flow versioning
later
{
  "payload": "some data" | "<some-xml></>" | "{\"a-stringified-json-payload\": true}"
}
Prepare your data

If you're passing in a payload via the request body, it must be stringified within a JSON object. For example:

Go to detailed steps ➜

Map your data

If you're passing in a payload via the request body for syncing to a target connection, your process flow will need a map shape - source data fields (for your incoming payload) should be added manually.

Go to detailed steps ➜

Get flow IDs

The initialise flow API request requires two identifiers - one for for the flow to be run and another for the specific flow version.

To find the process flow id, access the required process flow from the dashboard. You'll find the process flow id above the title at the top of the canvas:

And you'll find all process flow version ids at the bottom of process flow settings:

Go to detailed steps ➜

Authenticate

To obtain a Patchworks token for API authentication, send a POST request to the following URL:

This request must include your Patchworks login credentials in the body:

Go to detailed steps ➜

Initialise flow

To initialise a process flow, send a POST request to the following URL:

Replacing <flowID> and <flowVERSION> with details for your required process flow noted previously, and authenticate with your Patchworks token.

Go to detailed steps ➜

Patchworks Core API
below
{
  "payload": "{\"a-stringified-json-payload\"}"
}
https://svc-fabric.pwks.co/api/v1/login
{
    "email": "[email protected]",
    "password": "mypassword123*"
}
https://start.wearepatchworks.com/api/v1/flows/<flowID>/start/<flowVERSION>

Initialising a process flow & sending data

Introduction

Having obtained a Patchworks token, it can be applied to an API request to initialise a process flow with your data passed in the request body.

You must control when your API requests are sent - the process flow trigger shape schedule cannot currently be used. With this in mind, please ensure that the default trigger shape in your process flow is not configured with any schedules.

The steps

Show me

Step 1 Create a POST request for the following endpoint:

...replacing <flowID> and <flowVERSION> with details for your required process flow noted .

This endpoint is for the Patchworks production environment.

Step 2 In the request headers, pass in the token obtained - this should be prefixed with the word Bearer - for example:

Step 3 In the request body, pass in the required payload - for example:

Remember that the payload must be provided as a JSON object with a payload key containing a string of data. For more information please see .

Step 4 Send the request - if successful, a 200 'flow initialised' response is given, together with a flow run id:

You can check the status of this flow run via the .

Obtaining a token for Patchworks API authentication

Introduction

Patchworks API requests must be authenticated with a bearer token. To obtain a token, you need to send a login request which includes credentials that you use to access the Patchworks dashboard.

The steps

Show me

Step 1 Create a POST request for the following endpoint:

This endpoint is for the Patchworks production environment.

Step 2 In the request body, add the email and password that you use to log into the Patchworks dashboard. You should add this as JSON - for example:

Step 3 Send the request - if successful, a token is returned. For example:

Access tokens are valid for 24 hours - for example: Issued: Wednesday 20th July at 10:03:08 GMT Expires: Tuesday 21st July at 10:03:08 GMT

Step 4 Save this token ready for use in your .

previously
previously
Preparing your data
run logs
initialise request
https://start.wearepatchworks.com/api/v1/flows/<flowID>/manual/<flowVERSION>
{
  "payload": "[{\"id\":1000000001,\"first_name\":\"Jane\",\"last_name\":\"Smith\"},{\"id\":1000000002,\"first_name\":\"George\",\"last_name\":\"Jones\"}]"
}
https://svc-fabric.pwks.co/api/v1/login
{
    "email": "[email protected]",
    "password": "mypassword123*"
}

Working with cross-reference lookup API requests

Introduction

The Patchworks API can be used to add and manage cross-reference lookups. Using the API you can work with:

  • Lookups

Authentication

All API requests must be authenticated with a Patchworks bearer token. To obtain a token, send a POST request to the following endpoint:

In the request body, add the email and password that you use to log into the Patchworks dashboard. You should add this as JSON - for example:

A successful response returns a token. Tokens are valid for 24 hours.

For detailed information about obtaining tokens, please see .

Required cross reference details

The Patchworks cross-reference lookup API accepts two identifiers as parameters:

Parameter
Summary

id

Having selected a cross-reference lookup to view/edit, the unique id can be found at the end of the URL - for example:

valueId

Having selected a cross-reference lookup to view/edit, each existing lookup row is displayed with a unique valueId in the id column:

Lookups API

Retrieve a list all cross-reference lookups

Summary

Retrieve a list of cross-reference lookups that have been installed or added by your organisation.

URL

Required headers

Authorization : Bearer token

Sample request

Retrieve a single cross-reference lookup

Summary

Retrieve basic details for a specific cross-reference lookup that has been installed or added by your organisation.

URL

Required headers

Authorization : Bearer token

Sample request

Create a new cross-reference lookup

Summary

Create a new cross-reference lookup for your organisation. The lookup is created without any mapping rows.

URL

Required headers

Authorization : Bearer token

Body parameters

Update a cross-reference lookup

Summary

Update basic details for a cross-reference lookup for your organisation.

URL

Required headers

Authorization : Bearer token

Body parameters

Delete a cross-reference lookup

Summary

Remove a cross-reference lookup (and all associated row values) for your organisation.

URL

Required headers

Authorization : Bearer token

Sample request

Lookup rows API

Retrieve a list of mapping row values for a cross-reference lookup

Summary

Retrieve a list of row values for a given lookup that has been installed or added by your organisation.

URL

Required headers

Authorization : Bearer token

Sample request

Retrieve mapping row values for a specific row within a cross-reference lookup

Summary

Retrieve mapping row values for a given row within a given cross-reference lookup that has been installed or added by your organisation.

URL

Required headers

Authorization : Bearer token

Create a new mapping row for a cross-reference lookup

Summary

Create a new mapping row for a cross-reference lookup that has been installed or added by your organisation.

URL

Required headers

Authorization : Bearer token

Body parameters

Update a mapping row for a cross-reference lookup

Summary

Update mapping row values for a cross-reference lookup that has been installed or added by your organisation.

URL

Required headers

Authorization : Bearer token

Body parameters

Delete a mapping row for a cross-reference lookup

Summary

Remove a given mapping row for a cross-reference lookup that has been installed or added by your organisation.

URL

Required headers

Authorization : Bearer token

Sample request

Related information

Sample response (200 OK)
Sample response (200 OK)
  • name (required) (string)

  • description (required) (string)

  • default_value (optional) (string)

  • Example:

    Sample request

    Sample response (200 OK)

  • name (optional) (string)

  • description (optional) (string)

  • default_value (optional) (string)

  • At least one parameter must be passed into the request.

    Example:

    Sample request

    Sample response (200 OK)

    Sample response (200 OK)

    Sample response (200 OK)

    Sample request

    Sample response (200 OK)

  • left_value (required) (string)

  • right_value (required) (string)

  • Example:

    Sample request

    Sample response (200 OK)

  • left_value (optional) (string)

  • right_value (optional) (string)

  • At least one parameter must be passed into the request.

    Example:

    Sample request

    Sample response (200 OK)

    Sample response (200 OK)

    {{id}}

    The unique identifier associated with the cross-reference lookup.

    {{valueID}}

    The unique identifier associated with the cross-reference lookup row (also known as a mapping row).

    Lookup rows
    Obtaining a token for Patchworks API authentication
    Core API
    https://svc-fabric.pwks.co/api/v1/login
    {
        "email": "[email protected]",
        "password": "mypassword123*"
    }
    GET https://app.wearepatchworks.com/core-main/api/v1/cross-reference-lookups
    curl -X GET "https://app.wearepatchworks.com/core-main/api/v1/cross-reference-lookups" \
    -H "Authorization: Bearer e1234&FSKFJmytoken"
    GET https://app.wearepatchworks.com/core-main/api/v1/cross-reference-lookups/{{id}}
    curl -X GET "https://app.wearepatchworks.com/core-main/api/v1/cross-reference-lookups/2" \
    -H "Authorization: Bearer e1234&FSKFJmytoken"
    POST https://https://app.wearepatchworks.com/core-main/api/v1/cross-reference-lookups
    PATCH https://app.wearepatchworks.com/core-main/api/v1/cross-reference-lookups/{{id}}
    DELETE https://app.wearepatchworks.com/core-main/api/v1/cross-reference-lookups/{{id}}
    curl -X DELETE "https://
    
    GET https://app.wearepatchworks.com/core-main/api/v1/cross-reference-lookups/{{id}}/cross-reference-lookup-values
    GET https://app.wearepatchworks.com/core-main/api/v1/cross-reference-lookups/{{id}}/cross-reference-lookup-values/{{valueID}}
    POST https://app.wearepatchworks.com/core-main/api/v1/cross-reference-lookups/{{id}}/cross-reference-lookup-values
    PATCH https://app.wearepatchworks.com/core-main/api/v1/cross-reference-lookups/{{id}}/cross-reference-lookup-values/{{valueId}}
    DELETE https://app.wearepatchworks.com/core-main/api/v1/cross-reference-lookups/{{id}}/cross-reference-lookup-values/{{valueId}}
    curl -X DELETE "https://app.wearepatchworks.com/core-main/api/v1/cross-reference-lookups/7/cross-reference-lookup-values/568" \
    -H "Authorization: Bearer e1234&FSKFJmytoken"
    {
        "data": [
            {
                "id": 2,
                "cross_reference_lookup_template_id": 10,
                "name": "American state name to ANSI Alpha 2",
                "description": "Mapping of state names and their respective ANSI alpha-2 codes",
                "default_value": null
            },
            {
                "id": 4,
                "cross_reference_lookup_template_id": 13,
                "name": "Area measurement to abbreviation",
                "description": "Mapping of area measurements and their abbreviations",
                "default_value": null
            },
            {
                "id": 6,
                "cross_reference_lookup_template_id": 4,
                "name": "Country name to Primary currency name",
                "description": "Mapping of country names and their primary currency names",
                "default_value": null
            },
            {
                "id": 5,
                "cross_reference_lookup_template_id": 16,
                "name": "Currency name to ISO 4217",
                "description": "Mapping of currency names and their respective ISO 4217 codes",
                "default_value": null
            },
            {
                "id": 7,
                "cross_reference_lookup_template_id": 11,
                "name": "Month name to abbreviation",
                "description": "Mapping of month names and their abbreviations",
                "default_value": null
            }
        ],
        "links": {
            "first": "http://core.wearepatchworks.com/api/v1/cross-reference-lookups?page=1",
            "last": "http://core.wearepatchworks.com/api/v1/cross-reference-lookups?page=1",
            "prev": null,
            "next": null
        },
        "meta": {
            "current_page": 1,
            "from": 1,
            "last_page": 1,
            "links": [
                {
                    "url": null,
                    "label": "&laquo; Previous",
                    "active": false
                },
                {
                    "url": "http://core.wearepatchworks.com/api/v1/cross-reference-lookups?page=1",
                    "label": "1",
                    "active": true
                },
                {
                    "url": null,
                    "label": "Next &raquo;",
                    "active": false
                }
            ],
            "path": "http://core.wearepatchworks.com/api/v1/cross-reference-lookups",
            "per_page": 50,
            "to": 5,
            "total": 5
        }
    }
    {
        "data": {
            "id": 2,
            "cross_reference_lookup_template_id": 10,
            "name": "American state name to ANSI Alpha 2",
            "description": "Mapping of state names and their respective ANSI alpha-2 codes",
            "default_value": null
        }
    }
    {
        "name": "New lookup name",
        "description": "New lookup description",
        "default_value": "New lookup default value"
    }
    curl -X POST "https://app.wearepatchworks.com/core-main/api/v1/cross-reference-lookups" \
    -H "Authorization: Bearer e1234&FSKFJmytoken" \
    -H "Content-Type: application/json" \
    -d '{
        "name": "Colour HEX Values",
        "description": "Convert long-form colours to HEX codes",
        "default_value": "FFFFFF"
    }'
    {
        "data": {
            "id": 9,
            "cross_reference_lookup_template_id": null,
            "name": "Colour HEX Values",
            "description": "Convert long-form colours to HEX codes",
            "default_value": "FFFFFF"
        }
    }
    {
        "name": "New lookup name",
        "description": "New lookup description"
        "default_value": "New lookup default value"
    }
    curl -X PATCH "https://app.wearepatchworks.com/core-main/api/v1/cross-reference-lookups/8" \
    -H "Authorization: Bearer e1234&FSKFJmytoken" \
    -H "Content-Type: application/json" \
    -d '{
        "name": "Colour HEX Codes",
        "description": "Convert long-form colours to HEX codes",
        "default_value": "000000"
    }'
    {
        "data": {
            "id": 9,
            "cross_reference_lookup_template_id": null,
            "name": "Colour HEX Codes",
            "description": "Convert long-form colours to HEX codes",
            "default_value": "000000"
        }
    }
    {
        "message": "Cross reference lookup deleted successfully."
    }
    curl -X GET "https://app.wearepatchworks.com/core-main/api/v1/cross-reference-lookups/7/cross-reference-lookup-values" \
    -H "Authorization: Bearer e1234&FSKFJmytoken"
    {
        "data": [
            {
                "id": 556,
                "left_value": "April",
                "right_value": "Apr"
            },
            {
                "id": 557,
                "left_value": "August",
                "right_value": "Aug"
            },
            {
                "id": 558,
                "left_value": "December",
                "right_value": "Dec"
            },
            {
                "id": 559,
                "left_value": "February",
                "right_value": "Feb"
            },
            {
                "id": 560,
                "left_value": "January",
                "right_value": "Jan"
            },
            {
                "id": 561,
                "left_value": "July",
                "right_value": "July"
            },
            {
                "id": 562,
                "left_value": "June",
                "right_value": "June"
            },
            {
                "id": 563,
                "left_value": "March",
                "right_value": "Mar"
            },
            {
                "id": 564,
                "left_value": "May",
                "right_value": "May"
            },
            {
                "id": 565,
                "left_value": "November",
                "right_value": "Nov"
            },
            {
                "id": 566,
                "left_value": "October",
                "right_value": "Oct"
            },
            {
                "id": 567,
                "left_value": "September",
                "right_value": "Sept"
            }
        ],
        "links": {
            "first": "http://core.wearepatchworks.com/api/v1/cross-reference-lookups/7/cross-reference-lookup-values?page=1",
            "last": "http://core.wearepatchworks.com/api/v1/cross-reference-lookups/7/cross-reference-lookup-values?page=1",
            "prev": null,
            "next": null
        },
        "meta": {
            "current_page": 1,
            "from": 1,
            "last_page": 1,
            "links": [
                {
                    "url": null,
                    "label": "&laquo; Previous",
                    "active": false
                },
                {
                    "url": "http://core.wearepatchworks.com/api/v1/cross-reference-lookups/7/cross-reference-lookup-values?page=1",
                    "label": "1",
                    "active": true
                },
                {
                    "url": null,
                    "label": "Next &raquo;",
                    "active": false
                }
            ],
            "path": "http://core.wearepatchworks.com/api/v1/cross-reference-lookups/7/cross-reference-lookup-values",
            "per_page": 50,
            "to": 12,
            "total": 12
        }
    }
    curl -X GET "https://app.wearepatchworks.com/core-main/api/v1/cross-reference-lookups/7/cross-reference-lookup-values/557
    -H "Authorization: Bearer e1234&FSKFJmytoken"
    {
        "data": {
            "id": 557,
            "left_value": "August",
            "right_value": "Aug"
        }
    }
    {
        "left_value": "Your required value",
        "right_value": "Your required value"
    }
    curl -X POST "https://app.wearepatchworks.com/core-main/api/v1/cross-reference-lookups/7/cross-reference-lookup-values" \
    -H "Authorization: Bearer e1234&FSKFJmytoken" \
    -H "Content-Type: application/json" \
    -d '{
        "left_value": "Test",
        "right_value": "TST"
    }'
    {
        "data": {
            "id": 568,
            "left_value": "Test",
            "right_value": "TST"
        }
    }
    {
        "left_value": "Your required value",
        "right_value": "Your required value"
    }
    curl -X PATCH "https://app.wearepatchworks.com/core-main/api/v1/cross-reference-lookups/7/cross-reference-lookup-values/568" \
    -H "Authorization: Bearer e1234&FSKFJmytoken" \
    -H "Content-Type: application/json" \
    -d '{
        "left_value": "NEWTest",
        "right_value": "NEWTST"
    }'
    {
        "data": {
            "id": 568,
            "left_value": "NEWTest",
            "right_value": "NEWTST"
        }
    }
    {
        "message": "Cross reference lookup value deleted successfully."
    }