# Implementing API requests

## Introduction  <a href="#introduction" id="introduction"></a>

Having [added a Patchworks service for your Inbound API connector](broken://pages/JDLEINO2uE0w0NHYWWIt), you can implement your own API requests to send required data to the Patchworks endpoint for that service. This page summarises the information that you will need to accomplish this task.

## Prerequisites <a href="#prerequisites" id="prerequisites"></a>

To implement API requests for sending data to a Patchworks service, you must have completed the following tasks in Patchworks:

* ​[Adding an Inbound API connector with a custom payload​](/product-documentation/patchworks-services/inbound-api/using-the-inbound-api-connector-with-patchworks-services/adding-an-inbound-api-connector-with-a-custom-payload.md)
* ​[Generating token credentials for API access​](/product-documentation/patchworks-services/inbound-api/using-the-inbound-api-connector-with-patchworks-services/generating-token-credentials-for-api-access.md)
* ​[Adding a Patchworks service for an inbound API connector​](/product-documentation/patchworks-services/inbound-api/using-the-inbound-api-connector-with-patchworks-services/adding-a-patchworks-service-for-an-inbound-api-connector.md)

## API implementation requirements <a href="#api-implementation-requirements" id="api-implementation-requirements"></a>

To implement API requests for sending custom data to a Patchworks service, you will need:

* [A Patchworks access token endpoint and OAuth credentials](#token-endpoint-and-oauth-credentials)
* [An endpoint URL for the required Patchworks service](#patchworks-service-endpoint-url)

### Token endpoint & OAuth credentials <a href="#token-endpoint-and-oauth-credentials" id="token-endpoint-and-oauth-credentials"></a>

You must provide a valid **access token** to POST custom data to a Patchworks service. To obtain access tokens, send a GET request to the Patchworks **token endpoint**, with your **OAuth client credentials**.&#x20;

Access tokens are valid for 24 hours - for example:&#x20;

Issued: Wednesday 20th July at 10:03:08 GMT \
Expires: Tuesday 21st July at 10:03:08 GMT

You can generate **OAuth client credentials** and view the required **token endpoint** from the **authentication** tab for your **Inbound API connector**. For details, please see: [Generating token credentials for API access](broken://pages/2HmxqqBcsiMWyjTFPvje).

#### **Suggested Best Practice**

To minimise the chance of any issues with rate limits, we advise obtaining an access token once a day and storing this for use in any requests (rather than requesting an access token every time you want to post data).

If you attempt to post data with an expired access token, Patchworks returns a 401 status code, which should be your trigger to request a new token.

### Patchworks service endpoint URL <a href="#patchworks-service-endpoint-url" id="patchworks-service-endpoint-url"></a>

To POST custom payload data to a Patchworks service, you need the URL for that service. Service URLs are always in the form:

<https://inbound.pwks.co/v1/\\[YOUR> COMPANY NAME]/\[VANITY URL]…where:

* \[YOUR COMPANY NAME] is auto-generated by Patchworks, based on the company name provided for implementation.
* \[VANITY URL] is your preferred text value to complete the URL.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.wearepatchworks.com/product-documentation/patchworks-services/inbound-api/using-the-inbound-api-connector-with-patchworks-services/implementing-api-requests.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
