# Stitch Import API Reference

## Introduction

The Stitch Import API enables you to push arbitrary data from a source to Stitch. The Import API acts as a receiving point for data that is sent to Stitch. The Import API will ‘listen’ for new data, which is then processed by Stitch as it’s received.

This API is a RESTful, method-oriented API that allows you to push data from a source (including those Stitch doesn’t currently have an integration for) and send it to Stitch. Each endpoint uses standard HTTP verbs like GET and POST, and will return standard HTTP response codes to indicate request status or errors.

The API is built to accept JSON requests and to return JSON in all responses, including errors.

### API functionality

Using the Import API, you can:

* Push data from a source to Stitch
* Check the status of the Import API
* Validate push requests and batches without persisting them to Stitch

### Accessing the API

Anyone with a Stitch account can use the Import API. If you don’t currently have an account, [sign up for a free trial here](https://www.stitchdata.com/).

After you create a Stitch account, refer to the [Managing Import API access tokens in Stitch](https://help.qlik.com/en-US/stitch/developers/import-api/guides/manage-import-api-access-tokens) guide for instructions on generating an Import API access token in the Stitch app.

**Note**: If you’re a Stitch Connect user, refer to the [Managing Import API access tokens via the Connect API](https://help.qlik.com/en-US/stitch/developers/stitch-connect/guides/manage-import-api-access-tokens) guide.

### API support

While the Import API is a certified Stitch integration, using it does require some technical knowledge. This means that Stitch will address bugs and issues with the API that are within Stitch’s infrastructure, but Stitch doesn’t provide assistance for building or maintaining the scripts that send data to the API.

The table below provides some examples of the types of requests Stitch will and will not provide assistance for.

| **Stitch Support can assist with:** | **Stitch Support does not assist with:** |
| --- | --- |
| <ul><li>Identifying and reporting Import API outages</li><li>Identifying and resolving issues within Stitch</li></ul> | <ul><li>Retrieving API access tokens</li><li>Writing scripts</li><li>Data typing in requests</li><li>Troubleshooting scripts or API requests</li><li>Troubleshooting open source scripts that use the Import API, e.g. <a href="https://help.qlik.com/en-US/stitch/integrations/import-api/faq" target="new">Google Sheets</a></li><li>Troubleshooting or using <a href="https://help.qlik.com/en-US/stitch/developers/import-api/#libraries-and-resources">open source libraries</a> for the Import API</li></ul> |

Refer to the [Import API guides and resources](https://help.qlik.com/en-US/stitch/developers/import-api/guides) for assistance when developing and testing your script.

Additionally, ask the [Stitch Community](https://community.qlik.com/t5/Support/ct-p/qlikSupport) if you’re still stuck.

## Base URLs

The base URL you use to interact with the Import API depends on the [data pipeline region](https://help.qlik.com/en-US/stitch/security/supported-data-pipeline-regions) your Stitch account is in.

For example: If your account is in the Europe (`eu-central-1`) region, you’ll use this base URL in your requests to the Import API: `https://api.eu-central-1.stitchdata.com`.

Information note **Tip:** Use the **Select your region** menu at the top right corner of this page to select your data pipeline region. This will display all API requests in this reference with the correct base URL for your region.

**Not sure what data pipeline region your account is in?** [Click here for help](https://help.qlik.com/en-US/stitch/security/supported-data-pipeline-regions#identify-data-pipeline-region).

| **Data pipeline region** | **Import API base URL** |
| --- | --- |
| North America (us-east-1) | https://api.stitchdata.com |
| Europe (eu-central-1) | https://api.eu-central-1.stitchdata.com |

Your base URL is currently set to: ``

**Note**: If your requests uses the incorrect base URL, the API will respond with a `401 - Unauthorzied` code and an error.

## Authentication

The Import API uses an [API access token](https://help.qlik.com/en-US/stitch/developers/import-api/guides/manage-import-api-access-tokens) to authenticate requests. Import API access tokens can be generated and managed in the **Integration Settings** page for any Import API integration in your [Stitch account](https://app.stitchdata.com/). If you’re a [Stitch Connect](https://help.qlik.com/en-US/stitch/developers/stitch-connect) user, you can also use the Connect API to [create Import API sources](https://help.qlik.com/en-US/stitch/developers/stitch-connect/guides/create-import-api-integration-with-stitch-connect) and [manage their access tokens](https://help.qlik.com/en-US/stitch/developers/stitch-connect/guides/manage-import-api-access-tokens).

Authentication is performed via bearer auth, where your Import API access token is provided in the header of your request as `-H 'Authorization: Bearer at_[IMPORT_API_ACCESS_TOKEN]'`.

Your API access token has write access to the Stitch integration schema or dataset in your destination. Because of this, API access tokens should be treated like passwords - don’t share them in publicly accessible places like Stackoverflow, GitHub, etc. **Note**: You also shouldn’t share your API access token with Stitch Support. If sharing requests, remember to redact the API access token before sending.

If an API access token is ever lost or compromised, you can revoke it and create a new token.

Refer to the [Managing Import API access tokens in Stitch](https://help.qlik.com/en-US/stitch/developers/import-api/guides/manage-import-api-access-tokens) guide for more info.

### Stitch client IDs

For some the [Push](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#push-data) and [Validate push request](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#validate-request) endpoints, you’ll need to include your Stitch client ID for every record contained in a request body. Your Stitch client ID is the unique ID associated with your Stitch account.

```
POST /v2/import/push
```

```
curl -X "POST" "https://api.stitchdata.com/v2/import/push" \
     -H 'Authorization: Bearer [ACCESS_TOKEN]' \
     -H 'Content-Type: application/json' \
     -d \
'[
    {
      "client_id": 7723,              /* Stitch client ID */
      "table_name": "customers",
      "sequence": 1565880017,
      "data": {
        "id": 4,
        "name": "Beamo"
      },
      "key_names": [
        "id"
      ],
      "action": "upsert"
    },
    {
      "client_id": 7723,              /* Stitch client ID */
      "table_name": "orders",
      "sequence": 1565838645,
      "key_names": [
        "order_id"
      ],
      "data": {
        "order_id": 561,
        "customer_id": 4
      },
      "action": "upsert"
    }
  ]'
```

To locate your client ID, sign into your Stitch account and look at the URL. The client ID is the four to six-digit number between `client` and `pipeline` in the URL.

For example: If the URL is `https://app.stitchdata.com/v2/client/7723/pipeline/connections`, the client ID would be `7723`.

A client ID may have multiple API access tokens associated with it, but an API access token will only ever be associated with a single client ID.

## Response Codes

The API will attempt to return [HTTP status codes](http://en.wikipedia.org/wiki/List_of_HTTP_status_codes) to indicate the success or failure of a request sent to the API.

In general:

* Codes in the `2xx` range indicate success
* Codes in the `4xx` range indicate an error with the request, such as an invalid API access token, missing client ID, malformed request body, etc.
* Codes in the `5xx` range indicate an issue with Stitch. Persistent `5xx` codes may indicate an outage, which you can monitor on [Stitch’s status page](https://status.stitchdata.com/).

Your application should handle each of the following statuses gracefully:

| **Code** | **Text** | **Description** |
| --- | --- | --- |
| **200** | OK | Success! New data was added as a result of the request. |
| **201** | Created | The request was accepted and will be processed later. New data will be added once the request is processed. |
| **202** | Accepted | The request was accepted, but cannot currently be processed due to an internal error. Data will be automatically re-processed. |
| **400** | Bad Request | The request includes malformed JSON/Transit, did not provide an array of records, or contains more than 20,000 records. |
| **401** | Unauthorized | Potential causes:<br><br><ul> <li>Invalid API access token</li> <li>Incorrect <a href="https://help.qlik.com/en-US/stitch/integrations/import-api/faq#base-urls">base URL</a> for your account’s data pipeline region</li></ul> |
| **403** | Forbidden | The request had a valid API token, but is not permitted. The `client_id` in the request body may be incorrect. |
| **404** | Not Found | Potential causes:<br><br><ul> <li>The URI requested is invalid</li> <li>Method is not allowed by the endpoint</li></ul> |
| **405** | Method Not Allowed | The request has an HTTP method that is not supported by the endpoint. `POST` and `GET` are supported by the Import API. |
| **413** | Request Entity Too Large | The size of the request body exceeded 20MB. |
| **415** | Unsupported Media Type | The content header of the request didn’t specify a supported media type, or specified an unsupported media type.<br><br>The Import API supports JSON (`application/json`) and Transit (`application/transit+json`). **Note**: Only the [Push](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#push-data) and [Validate push request](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#validate-request) endpoints accept Transit. |
| **422** | Unprocessable Entity | The request body is missing a required argument. |
| **503** | Service Unavailable | The Import API is experiencing problems. Try again later. |
| **504** | Gateway Timeout | The Import API couldn’t process the request in time due to an internal error. Try again later. |

### Response and error message formats

The API will return responses - successful or errors - in JSON format. Below are descriptions and examples of each type of response.

#### Response message formats

For successful responses (codes in the `2xx` range) the API will return messages as a JSON object:

```

```

```
{
  "status": "OK",
  "message": "Batch Accepted!"
}
```

In the Import API documentation, this is referred to as a [Batch Status object](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#batch-status-object).

#### Error message formats

For error responses (codes in the `4xx` range), the API will return error messages in JSON format. In the Import API documentation, this is referred to as an [Error object](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#error-object).

Some error messages may be returned as strings:

```

```

```
Content-Type must be application/json
```

While others may be JSON objects:

```

```

```
{
  "status": "ERROR",
  "error": "Forbidden",
  "errors": {
    "error": "Access token is not associated with this client."
  }
}
```

#### Error message text

The text in error messages will vary by root cause and endpoint.

Each endpoint section contains a list of the errors specific to that endpoint. Refer to the documentation for the endpoint for specifics on errors, their possible causes, and the messages the API will return.

## Versioning

When we make backwards-incompatible changes to the API, we release a new version. The current version of the Import API is **2**.

## Methods

### API Status

An object describing the status of the Import API at the time a request is sent.

#### Endpoints

| GET | **[Get Import API status](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#get-status)** | Determines if the Import API is operating correctly. This endpoint doesn’t require any authentication. |
| --- | --- | --- |

OBJECT

#### The API Status object

An object describing the status of the Import API at the time a request is sent.

| **name**<br><br><br><br>STRING | This will always be `pipeline.gate`. |
| --- | --- |
| **version**<br><br><br><br>STRING | **Stitch internal field**. |
| **revision**<br><br><br><br>STRING | **Stitch internal field**. |
| **status**<br><br><br><br>STRING | The status of the Import API at the time of the request. |
| **reason**<br><br><br><br>STRING | If applicable, the reason for the status. |

##### Example object

```

```

```
{
  "name": "pipeline.gate",
  "version": "0.3.3-SNAPSHOT",
  "revision": "a154360ad8c43182965049dbf6239aa7c1f3c84d",
  "status": "OK",
  "reason": null
}
```

GET

#### Get Import API status

Determines if the Import API is operating correctly. This endpoint doesn’t require any authentication.

##### Resource list

| **Request method** | GET |
| --- | --- |
| **Base URL** | The correct [base URL](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#base-urls) for your Stitch data pipeline region.<br><br>Your base URL is currently set to: `` |
| **Resource URL** | /v2/import/status |
| **Authorization** | Not required. |
| **Request header** | Not required.<br><br>See the **Request** tab below for example requests. |
| **Request body** | The request body must be valid JSON or Transit and contain the [required arguments](https://help.qlik.com/en-US/stitch/developers/import-api/api#get-status--arguments). |
| **Response format** | Whether the request succeeds or fails, the API will return JSON. |

##### Returns

If successful, the API will return a `200 OK` status and an [API status](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#api-status--object) object.

* Request
* Response

```

        GET /v2/import/status

    
```

```
curl "https://api.stitchdata.com/v2/import/status"
```

```

        Response for GET /v2/import/status

    
```

```
{
  "name": "pipeline.gate",
  "version": "0.3.3-SNAPSHOT",
  "revision": "a154360ad8c43182965049dbf6239aa7c1f3c84d",
  "status": "OK",
  "reason": null
}
```

### Batch

An object containing a table name, a table schema, and message objects representing records to be pushed to Stitch.

Information note **Note**: This endpoint and the Push endpoint have some key differences, even though both endpoints will send data to Stitch. **We recommend using the Batch endpoint for the best data typing experience.** Refer to the [Structuring data for the Import API guide](https://help.qlik.com/en-US/stitch/developers/import-api/guides/structure-data-for-the-import-api#endpoints) for a comparison of both endpoints.

#### Endpoints

| POST | **[Create a batch](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#batch-data)** | Pushes data for a specified table to Stitch. |
| --- | --- | --- |

OBJECT

#### The Batch object

An object containing a table name, a table schema, and message objects representing records to be pushed to Stitch.

| **table\_name**<br><br><br><br>STRING | The name of the destination table the data is being pushed to. Table names must be unique in each destination schema, or loading issues will occur.<br><br>**Note**: The number of characters in the table name should be within the destination’s allowed limits or data will rejected. |
| --- | --- |
| **schema**<br><br><br><br>OBJECT<br><br><br>([SCHEMA](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#schema-object)) | A [Schema object](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#schema-object) containing the JSON schema describing the record(s) in the [Message object’s](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#message-object) `data` property.<br><br>Records must conform to this schema or an error will be returned when the request is sent. |
| **messages**<br><br><br><br>ARRAY<br><br><br>([MESSAGE](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#message-object)) | An array of [Message](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#message-object) objects, each representing a record to be upserted into the table. |
| **key\_names**<br><br><br><br>ARRAY | An array of strings representing the Primary Key fields in the source table. **Note**: A value must be provided, but it may be an empty list to indicate that the source table doesn’t have a Primary Key.<br><br>If fields are provided, they must comply with the following:<br><br><ol> <li>Each field in the list must be the name of a top-level property defined in the <a href="https://help.qlik.com/en-US/stitch/integrations/import-api/faq#schema-object">Schema object</a>. Primary Key fields cannot be contained in an object or an array.</li> <li>Fields in the list may not be <code>null</code> in the source.</li> <li>If a field is a string, its value must be less than 256 characters.</li></ol><br><br>All fields included in `key_names` must be present in the [Schema object](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#schema-object) and every [Message object](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#message-object) in the request. |

##### Example object

```

```

```
{
  "table_name": "customers",
  "schema": {
    "properties": {
      "id": {
        "type": "integer"
      },
      "name": {
        "type": "string"
      },
      "age": {
        "type": "integer"
      },
      "has_magic": {
        "type": "boolean"
      }
    }
  },
  "messages": [
    {
      "action": "upsert",
      "sequence": 1565880017,
      "data": {
        "id": 1,
        "name": "Finn",
        "age": 15,
        "has_magic": false
      }
    }
  ],
  "key_names": [
    "id"
  ]
}
```

POST

#### Create a batch

Pushes a record or multiple records for a specified table to Stitch. Each request to this endpoint may only contain data for a single table.

When data for a table is pushed for the first time, Stitch will create the table in the destination in the specified integration schema.

How data is loaded during subsequent pushes depends on:

1. **The loading behavior types used by the destination**. Stitch supports [Upsert](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#) and [Append-Only](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#) loading.
2. **Whether the `key_names` property specifies Primary Key fields.** If Primary Keys aren’t specified, data will be loaded using Append-Only loading.

Refer to the [Understanding loading behavior guide](https://help.qlik.com/en-US/stitch/replication/loading/understanding-loading-behavior) for more info and examples.

#### Structuring request body data

Refer to the [Structuring data for the Import API guide](https://help.qlik.com/en-US/stitch/developers/import-api/guides/structure-data-for-the-import-api) for instructions and examples.

##### Resource list

| **Request method** | POST |
| --- | --- |
| **Base URL** | The correct [base URL](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#base-urls) for your Stitch data pipeline region.<br><br>Your base URL is currently set to: `` |
| **Resource URL** | /v2/import/batch |
| **Authorization** | Required. The request header must contain **Authorization** and your Import API access token. |
| **Request header** | The request header must contain the following:<br><br><ul> <li> <p><strong>Authorization</strong>: Must specify Bearer Auth, e.g. <code>Bearer: &lt;ACCESS_TOKEN&gt;</code></p> </li> <li> <p><strong>Content-Type</strong>: Must specify JSON, e.g. <code>application/json</code></p> </li></ul><br><br>See the **Request** tab below for example requests. |
| **Request body** | The request body must be valid JSON and contain the [required arguments](https://help.qlik.com/en-US/stitch/developers/import-api/api#batch-data--arguments).<br><br>The request body must also comply with the following:<br><br><ul> <li> <p>Must contain all <a href="https://help.qlik.com/en-US/stitch/integrations/import-api/faq#batch-data--arguments">required arguments</a>.</p> </li> <li> <p>Cannot exceed 20MB in size.</p> </li> <li> <p>Each <code>data</code> object in the request body must contain between 1 and 20,000 records.</p> </li> <li> <p>Each <code>data</code> object in the request body cannot exceed 10,000 individual data points.</p> </li> <li> <p>Must contain data only for a single table.</p> </li></ul> |
| **Response format** | Whether the request succeeds or fails, the API will return JSON. |
| **Errors** | See the **Errors** tab, below. |

##### Arguments

This endpoint accepts the following parameters:

| **table\_name**<br><br><br><br>STRING<br><br><br><br><br><br><br><br><br><br><br>REQUIRED | The name of the destination table the data is being pushed to. Table names must be unique in each destination schema, or loading issues will occur.<br><br>**Note**: The number of characters in the table name should be within the destination’s allowed limits or data will rejected. |
| --- | --- |
| **schema**<br><br><br><br>OBJECT<br><br><br>([SCHEMA](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#schema-object))<br><br><br><br><br><br><br><br><br><br>REQUIRED | A [Schema object](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#schema-object) containing the JSON schema describing the record(s) in the [Message object’s](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#message-object) `data` property.<br><br>Records must conform to this schema or an error will be returned when the request is sent. |
| **messages**<br><br><br><br>ARRAY<br><br><br>([MESSAGE](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#message-object))<br><br><br><br><br><br><br><br><br><br>REQUIRED | An array of [Message](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#message-object) objects, each representing a record to be upserted into the table. |
| **key\_names**<br><br><br><br>ARRAY<br><br><br><br><br><br><br><br><br><br><br>OPTIONAL | An array of strings representing the Primary Key fields in the source table. Stitch use these Primary Keys to de-dupe data during loading. If not provided, the table will be loaded in an append-only manner.<br><br>**Note**: If included, a value must be provided. However, it may be an empty list to indicate that the source table doesn’t have a Primary Key.<br><br>If fields are provided, they must adhere to the following:<br><br><ol> <li>Each field in the list must be the name of a top-level property defined in the <a href="https://help.qlik.com/en-US/stitch/integrations/import-api/faq#schema-object">Schema object</a>. Primary Key fields cannot be contained in an object or an array.</li> <li>Fields in the list may not be <code>null</code> in the source.</li> <li>If a field is a string, its value must be less than 256 characters.</li></ol><br><br>All fields included in `key_names` must be present in the [Schema object](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#schema-object) and every [Message object](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#message-object) in the request. |

##### Returns

If successful, the API will return a `2xx` status and a [Batch status object](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#batch-status-object):

* `201` - The request was accepted and will be processed later. New data will be added once the request is processed.

* `202` - The request was accepted, but cannot currently be processed due to an internal error. Data will be automatically re-processed.

* Request
* Response
* Errors

**Requests for POST /v2/import/batch**

```

            Pushing a single record
        
```

```
curl -X "POST" "https://api.stitchdata.com/v2/import/batch" \
     -H 'Authorization: Bearer [ACCESS_TOKEN]' \
     -H 'Content-Type: application/json' \
     -d \
'{
    "table_name": "customers",
    "schema": {
      "properties": {
        "id": {
          "type": "integer"
        },
        "name": {
          "type": "string"
        },
        "age": {
          "type": "integer"
        },
        "has_magic": {
          "type": "boolean"
        },
        "modified_at":{
            "type":"string",
            "format":"date-time"
         }
      }
    },
    "messages": [
      {
        "action": "upsert",
        "sequence": 1565880017,
        "data": {
          "id": 1,
          "name": "Finn",
          "age": 15,
          "has_magic": false,
          "modified_at":"2020-01-13T21:25:03+0000"
        }
      }
    ],
    "key_names": [
      "id"
    ]
  }'
```

```

            Pushing multiple records
        
```

```
curl -X "POST" "https://api.stitchdata.com/v2/import/batch" \
     -H 'Authorization: Bearer [ACCESS_TOKEN]' \
     -H 'Content-Type: application/json' \
     -d \
'{
   "table_name":"customers",
   "schema":{
      "properties":{
         "id":{
            "type":"integer"
         },
         "name":{
            "type":"string"
         },
         "age":{
            "type":"integer"
         },
         "has_magic":{
            "type":"boolean"
         },
         "modified_at":{
            "type":"string",
            "format":"date-time"
         }
      }
   },
   "messages":[
      {
         "action":"upsert",
         "sequence":1565881320,
         "data":{
            "id":2,
            "name":"Jake",
            "age":6,
            "has_magic":true,
            "modified_at":"2020-01-13T21:25:03+0000"
         }
      },
      {
         "action":"upsert",
         "sequence":1565838645,
         "data":{
            "id":3,
            "name":"Bubblegum",
            "age":17,
            "has_magic":true,
            "modified_at":"2020-01-14T13:34:25+0000"
         }
      }
   ],
   "key_names":[
      "id"
   ]
}'
```

```

            Pushing a record without a Primary Key
        
```

```
curl -X "POST" "https://api.stitchdata.com/v2/import/batch" \
     -H 'Authorization: Bearer [ACCESS_TOKEN]' \
     -H 'Content-Type: application/json' \
     -d \
'{
   "table_name":"customers_no_primary_keys",
   "schema":{
      "properties":{
         "name":{
            "type":"string"
         },
         "age":{
            "type":"integer"
         },
         "has_magic":{
            "type":"boolean"
         },
         "modified_at":{
            "type":"string",
            "format":"date-time"
         }
      }
   },
   "messages":[
      {
         "action":"upsert",
         "sequence":1565881320,
         "data":{
            "name":"BMO",
            "age":2,
            "has_magic":false,
            "modified_at":"2020-01-20T05:57:01+0000"
         }
      }
   ]
}'
```

**Responses for POST /v2/import/batch**

```

            
        
```

```

{
  "status": "OK",
  "message": "Batch Accepted!"
}
```

```

            
        
```

```

{
  "status": "Accepted",
  "message": "The batch is queued to be processed."
}
```

| **Code** | **Condition** | **Response body** |
| --- | --- | --- |
| **400** | Request body is missing required arguments | ```<br>{<br>"error": "Request failed validation:#: required key [<ARGUMENT_NAME>] not found"<br>}<br>``` |
| **400** | Request body contains an illegal argument | ```<br>{<br>"error": "Request failed validation:#: extraneous key [<ARGUMENT_NAME>] is not permitted"<br>}<br>``` |
| **400** | Required argument is incorrectly typed | ```<br>{<br>"error": "Request failed validation:#/<ARGUMENT_NAME>: expected type: <CORRECT_TYPE>, found: <TYPE>"<br>}<br>``` |
| **400** | Record in Message object doesn’t conform to the Schema | ```<br>{<br>"error": "Record 0 did not conform to schema: #/<FIELD_NAME>: expected: <DATA_TYPE>, found: <DATA_TYPE>"<br>}<br>``` |
| **400** | `key_names` are provided, but a record has a missing or `null` key value | ```<br>{<br>"error": "Record is missing key property <KEY_NAME>"<br>}<br>``` |
| **400** | Invalid [JSON data type](https://json-schema.org/understanding-json-schema/reference/type.html) in Schema object | ```<br>{<br>"error": "Invalid JSON schema: unknown type: [<TYPE>]"<br>}<br>``` |
| **400** | Required argument missing from the Message object | ```<br>{<br>"error": "Request failed validation:#/messages/0: #: 0 subschemas matched instead of one #/messages/0: 2 schema violations found #/messages/0: required key [<ARGUMENT_NAME>] not found #/messages/0: extraneous key [data] is not permitted #/messages/0: required key [ARGUMENT_NAME] not found"<br>}<br>``` |
| **400** | Value of the `sequence` argument exceeds allowed maximum value | ```<br>{<br>"error": "Request failed validation:#: sequence can not be above 9223372036854775807"<br>}<br>``` |
| **400** | The Schema object must be an object, not an array | ```<br>{<br>"error": "Request failed validation:#/schema: expected type: JSONObject, found: JSONArray"<br>}<br>``` |
| **401** | Access token is missing or invalid | ```<br>{<br>"message":"Not Authorized"<br>}<br>``` |
| **401** | Base URL doesn’t match account region | ```<br>{<br>"message": "Invalid region."<br>}<br>``` |
| **401** | Integration is paused or has been deleted | ```<br>{<br>"error": "Forbidden",<br>"errors": {<br>"error": "Connection is not active."<br>}<br>}<br>``` |
| **413** | Request body exceeds 20MB | ```<br>{<br>"status": "ERROR",<br>"message": "Request rejected: request size (<BYTE>s bytes) exceeds the maximum"<br>}<br>``` |
| **415** | Unsupported content type | `Content-Type must be application/json` |

### Validate

An object containing table information, your client ID, and data objects representing records to be validated without being persisted to Stitch. The Validate object is identical to the [Push object](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#push--object).

#### Endpoints

| POST | **[Validate a push request](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#validate-request)** | Validates request credentials and batch data, but doesn’t persist the data to Stitch. This allows you to validate your API credentials and batch data during development. |
| --- | --- | --- |

OBJECT

#### The Validate object

An object containing table information, your client ID, and data objects representing records to be validated without being persisted to Stitch. The Validate object is identical to the [Push object](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#push--object).

| **client\_id**<br><br><br><br>INTEGER | The Stitch client ID associated with your Stitch account.<br><br>To locate your client ID, sign into your Stitch account and look at the URL. The client ID is the four to six-digit number between `client` and `pipeline` in the URL.<br><br>For example: If the URL is `https://app.stitchdata.com/v2/client/7723/pipeline/connections`, the client ID would be `7723`. |
| --- | --- |
| **table\_name**<br><br><br><br>STRING | The name of the destination table the data is being pushed to. Table names must be unique in each destination schema, or loading issues will occur.<br><br>A single request can push data to multiple tables.<br><br>**Note**: The number of characters in the table name should be within the destination’s allowed limits or data will rejected. |
| **sequence**<br><br><br><br>INTEGER | An integer that tells the Import API the order in which data points in the request body should be considered for loading. This data will be stored in the destination table in the `_sdc_sequence` column.<br><br>In other Stitch integrations, Stitch uses a Unix epoch (in milliseconds) as the value for this property.<br><br>**Note**: This value cannot exceed the maximum of `9223372036854775807`. |
| **action**<br><br><br><br>STRING | This will always be `upsert`. |
| **key\_names**<br><br><br><br>ARRAY | An array of strings representing the Primary Key fields in the destination table.<br><br><ul> <li>All fields defined as Primary Keys must be present in the <code>data</code> object and their value cannot be <code>null</code></li> <li>If a Primary Key is a string, its value must be less than 256 characters</li> <li>Primary Key fields must be top-level fields in the table. For example: When sending JSON, a Primary Key field cannot be contained in an object or an array.</li></ul> |
| **data**<br><br><br><br>OBJECT | An object representing a record to be pushed into the destination table.<br><br><ul> <li>All fields included in <code>key_names</code> must be included and their values cannot be <code>null</code></li> <li>The maximum number of data points per <code>data</code> object is 10,000</li> <li>If a Primary Key is a string, its value must be less than 256 characters</li></ul><br><br>Refer to the [Structuring data for the Import API guide](https://help.qlik.com/en-US/stitch/developers/import-api/guides/structure-data-for-the-import-api) for instructions and examples. |

##### Example object

```

```

```
{
  "client_id":7723,
  "table_name":"customers",
  "sequence":1565880017,
  "data":{
     "id":1,
     "name":"Finn"
  },
  "key_names":[
     "id"
  ],
  "action":"upsert"
}
```

POST

#### Validate a push request

**Note**: With the exception of not persisting data, this endpoint is functionally identical to the [Push endpoint](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#push-data). The Validate endpoint will not work if a request body intended for the [Batch endpoint](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#batch-data) is sent.

Validates request credentials and batch data, but doesn’t persist the data to Stitch. This allows you to validate your API credentials and batch data during development.

Regardless of whether the Import API is functional, this endpoint will never return a `503 Service Unavailable` response. Use the [Status endpoint](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#get-status) to determine if the Import API is experiencing issues.

##### Resource list

| **Request method** | POST |
| --- | --- |
| **Base URL** | The correct [base URL](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#base-urls) for your Stitch data pipeline region.<br><br>Your base URL is currently set to: `` |
| **Resource URL** | /v2/import/validate |
| **Authorization** | Required. The request header must contain **Authorization** and your Import API access token. |
| **Request header** | The request header must contain the following:<br><br><ul> <li> <p><strong>Authorization</strong>: Must specify Bearer Auth, e.g. <code>Bearer: &lt;ACCESS_TOKEN&gt;</code></p> </li> <li> <p><strong>Content-Type</strong>: Must specify JSON, e.g. <code>application/json</code></p> </li></ul><br><br>See the **Request** tab below for example requests. |
| **Request body** | The request body must be valid JSON or Transit and contain the [required arguments](https://help.qlik.com/en-US/stitch/developers/import-api/api#validate-request--arguments).<br><br>The request body should provide an array (batch) of records to be inserted into the pipeline that comply with the following:<br><br><ul> <li> <p>Must contain all <a href="https://help.qlik.com/en-US/stitch/integrations/import-api/faq#[NAME]-data--arguments">required arguments</a>.</p> </li> <li> <p>Cannot exceed {{ site.data.import-api.general.max-record-size }} in size.</p> </li> <li> <p>Each <code>data</code> object in the request body must contain between 1 and 20,000 records.</p> </li> <li> <p>Each <code>data</code> object in the request body cannot exceed 10,000 individual data points.</p> </li> <li> <p>Must contain a valid <code>client_id</code>. Each record in the request body must have the same <code>client_id</code>.</p> </li> <li> <p>Must be an array (batch) of records. The root cannot be an object.</p> </li></ul> |
| **Response format** | Whether the request succeeds or fails, the API will return JSON. |
| **Errors** | See the **Errors** tab, below. |

##### Arguments

This endpoint accepts the following parameters:

| **client\_id**<br><br><br><br>INTEGER<br><br><br><br><br><br><br><br><br><br><br>REQUIRED | The Stitch client ID associated with your Stitch account.<br><br>To locate your client ID, sign into your Stitch account and look at the URL. The client ID is the four to six-digit number between `client` and `pipeline` in the URL.<br><br>For example: If the URL is `https://app.stitchdata.com/v2/client/7723/pipeline/connections`, the client ID would be `7723`.<br><br>**Note**: This must be the same for every record in the request body. |
| --- | --- |
| **table\_name**<br><br><br><br>STRING<br><br><br><br><br><br><br><br><br><br><br>REQUIRED | The name of the destination table the data is being pushed to. Table names must be unique in each destination schema, or loading issues will occur.<br><br>A single request can push data to multiple tables.<br><br>**Note**: The number of characters in the table name should be within the destination’s allowed limits or data will rejected. |
| **sequence**<br><br><br><br>INTEGER<br><br><br><br><br><br><br><br><br><br><br>REQUIRED | An integer that tells the Import API the order in which data points in the request body should be considered for loading. This data will be stored in the destination table in the `_sdc_sequence` column.<br><br>In other Stitch integrations, Stitch uses a Unix epoch (in milliseconds) as the value for this property.<br><br>**Note**: This value cannot exceed the maximum of `9223372036854775807`. |
| **action**<br><br><br><br>STRING<br><br><br><br><br><br><br><br><br><br><br>REQUIRED | This will always be `upsert`. |
| **key\_names**<br><br><br><br>ARRAY<br><br><br><br><br><br><br><br><br><br><br>REQUIRED | An array of strings representing the Primary Key fields in the destination table.<br><br><ul> <li>All fields defined as Primary Keys must be present in the <code>data</code> object and their value cannot be <code>null</code></li> <li>If a Primary Key is a string, its value must be less than 256 characters</li> <li>Primary Key fields must be top-level fields in the table. For example: When sending JSON, a Primary Key field cannot be contained in an object or an array.</li></ul> |
| **data**<br><br><br><br>OBJECT<br><br><br><br><br><br><br><br><br><br><br>REQUIRED | An object representing a record to be pushed into the destination table.<br><br><ul> <li>All fields included in <code>key_names</code> must be included and their values cannot be <code>null</code></li> <li>The maximum number of data points per <code>data</code> object is 10,000</li> <li>If a Primary Key is a string, its value must be less than 256 characters</li></ul><br><br>Refer to the [Structuring data for the Import API guide](https://help.qlik.com/en-US/stitch/developers/import-api/guides/structure-data-for-the-import-api) for instructions and examples. |

##### Returns

If successful, the API will return a `200 OK` status and a [Batch Status object](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#batch-status-object).

* Request
* Response
* Errors

```

        POST /v2/import/validate

    
```

```
curl -X "POST" "https://api.stitchdata.com/v2/import/validate" \
     -H 'Authorization: Bearer [ACCESS_TOKEN]' \
     -H 'Content-Type: application/json' \
     -d \
'[
   {
      "client_id":7723,
      "table_name":"customers",
      "sequence":1565881320,
      "key_names":[
         "id"
      ],
      "data":{
         "id":1,
         "name":"Finn"
      },
      "action":"upsert"
   }
]'
```

```

        Response for POST /v2/import/validate

    
```

```
{
  "status": "OK",
  "message": "Batch is valid!"
}
```

| **Code** | **Condition** | **Response body** |
| --- | --- | --- |
| **400** | Request body is not an array | ```<br>{<br>"status": "ERROR",<br>"message": "An array of records is expected"<br>}<br>``` |
| **400** | Request body is malformed | ```<br>{<br>"status": "ERROR",<br>"message": "Malformed json in the body!",<br>"error": "Unexpected character (']' (code 93)): expected a value\n at [Source: java.io.StringReader@796a657e; line: 16, column: 2]",<br>"input": null<br>}<br>``` |
| **401** | Base URL doesn’t match account region | ```<br>{<br>"message": "Invalid region."<br>}<br>``` |
| **401** | `client_id` missing from request body | ```<br>{<br>"status": "ERROR",<br>"error": "Not Authenticated.",<br>"errors": null<br>}<br>``` |
| **401** | Integration is paused or has been deleted | ```<br>{<br>"error": "Forbidden",<br>"errors": {<br>"error": "Connection is not active."<br>}<br>}<br>``` |
| **403** | `client_id` and access token mismatch | ```<br>{<br>"status": "ERROR",<br>"error": "Forbidden",<br>"errors": {<br>"error": "Access token is not associated with this client."<br>}<br>}<br>``` |
| **405** | Unsupported method | `Method not allowed.` |
| **413** | Request body exceeds 20MB | ```<br>{<br>"status": "ERROR",<br>"message": "Request rejected: request size (<BYTE>s bytes) exceeds the maximum"<br>}<br>``` |
| **415** | Unsupported content type | ```<br>{<br>"status": "ERROR",<br>"message": "Unsupported content-type application/<TYPE>. Please send application/json or application/transit+json"<br>}<br>``` |
| **422** | Multiple client IDs in request | ```<br>{<br>"status": "ERROR",<br>"error": "Request cannot be processed; see errors.",<br>"errors": [<br>{<br>"reason": "The batch contains data points for multiple clients. Only client_id <CLIENT_ID> is allowed"<br>}<br>]<br>}<br>``` |
| **422** | Required argument is missing or blank | ```<br>{<br>"status": "ERROR",<br>"error": "Request cannot be processed; see errors.",<br>"errors": [<br>{<br>"<REQUIRED_ARGUMENT_NAME>": {<br>"table_name": [<br>"can't be blank"<br>]<br>}<br>}<br>]<br>}<br>``` |
| **422** | Required argument is incorrectly typed | ```<br>{<br>"status": "ERROR",<br>"error": "Request cannot be processed; see errors.",<br>"errors": [<br>{<br>"reason": {<br>"sequence": [<br>"should be an integer",<br>"should be a number"<br>]<br>}<br>}<br>]<br>}<br>``` |
| **422** | `data` must be typed as an object | ```<br>{<br>"status": "ERROR",<br>"error": "Request cannot be processed; see errors.",<br>"errors": [<br>{<br>"reason": {<br>"data": [<br>"data must be an object"<br>]<br>}<br>}<br>]<br>}<br>``` |
| **422** | `data` must include fields in `key_names` | ```<br>{<br>"status": "ERROR",<br>"error": "Request cannot be processed; see errors.",<br>"errors": [<br>{<br>"reason": {<br>"data": [<br>"data must include keys"<br>]<br>}<br>}<br>]<br>}<br>``` |
| **422** | Key values in `data` cannot be null | ```<br>{<br>"status": "ERROR",<br>"error": "Request cannot be processed; see errors.",<br>"errors": [<br>{<br>"reason": {<br>"data": [<br>"keys cannot not be null in data"<br>]<br>}<br>}<br>]<br>}<br>``` |
| **422** | Key names not provided | ```<br>{<br>"status": "ERROR",<br>"error": "Request cannot be processed; see errors.",<br>"errors": [<br>{<br>"reason": {<br>"key_names": [<br>"can't be blank"<br>],<br>"key_properties": [<br>"unknown key"<br>]<br>}<br>}<br>]<br>}<br>``` |
| **422** | String values in key fields cannot exceed 1,024 characters | ```<br>{<br>"status": "ERROR",<br>"error": "Request cannot be processed; see errors.",<br>"errors": [<br>{<br>"reason": {<br>"data": [<br>"String keys cannot be longer than 1024 characters"<br>]<br>}<br>}<br>]<br>}<br>``` |

### Push

An object containing table information, your client ID, and data objects representing records to be pushed to Stitch.

Information note **Note**: This endpoint and the Batch endpoint have some key differences, even though both endpoints will send data to Stitch. Refer to the [Structuring data for the Import API guide](https://help.qlik.com/en-US/stitch/developers/import-api/guides/structure-data-for-the-import-api#endpoints) for a comparison of both endpoints.

#### Endpoints

| POST | **[Push data](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#push-data)** | Pushes data for a specified table or tables to Stitch. |
| --- | --- | --- |

OBJECT

#### The Push object

An object containing table information, your client ID, and data objects representing records to be pushed to Stitch.

| **client\_id**<br><br><br><br>INTEGER | The Stitch client ID associated with your Stitch account.<br><br>To locate your client ID, sign into your Stitch account and look at the URL. The client ID is the four to six-digit number between `client` and `pipeline` in the URL.<br><br>For example: If the URL is `https://app.stitchdata.com/v2/client/7723/pipeline/connections`, the client ID would be `7723`. |
| --- | --- |
| **table\_name**<br><br><br><br>STRING | The name of the destination table the data is being pushed to. Table names must be unique in each destination schema, or loading issues will occur.<br><br>A single request can push data to multiple tables.<br><br>**Note**: The number of characters in the table name should be within the destination’s allowed limits or data will rejected. |
| **sequence**<br><br><br><br>INTEGER | An integer that tells the Import API the order in which data points in the request body should be considered for loading. This data will be stored in the destination table in the `_sdc_sequence` column.<br><br>In other Stitch integrations, Stitch uses a Unix epoch (in milliseconds) as the value for this property.<br><br>**Note**: This value cannot exceed the maximum of `9223372036854775807`. |
| **action**<br><br><br><br>STRING | This will always be `upsert`. |
| **key\_names**<br><br><br><br>ARRAY | An array of strings representing the Primary Key fields in the destination table.<br><br><ul> <li>All fields defined as Primary Keys must be present in the <code>data</code> object and their value cannot be <code>null</code></li> <li>If a Primary Key is a string, its value must be less than 256 characters</li> <li>Primary Key fields must be top-level fields in the table. For example: When sending JSON, a Primary Key field cannot be contained in an object or an array.</li></ul> |
| **data**<br><br><br><br>OBJECT | An object representing a record to be pushed into the destination table.<br><br><ul> <li>All fields included in <code>key_names</code> must be included and their values cannot be <code>null</code></li> <li>The maximum number of data points per <code>data</code> object is 10,000</li> <li>If a Primary Key is a string, its value must be less than 256 characters</li></ul><br><br>Refer to the [Structuring data for the Import API guide](https://help.qlik.com/en-US/stitch/developers/import-api/guides/structure-data-for-the-import-api) for instructions and examples. |

##### Example object

```

```

```
{
  "client_id":7723,
  "table_name":"customers",
  "sequence":1565880017,
  "data":{
     "id":1,
     "name":"Finn"
  },
  "key_names":[
     "id"
  ],
  "action":"upsert"
}
```

POST

#### Push data

Information note

**Need to enforce data types?**

We recommend using the [Create a batch](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#batch-data) endpoint instead. The Batch endpoint allows you to specify a schema and enforce data types, while this endpoint does not.

Pushes data for a specified table or tables to Stitch.

When data for a table is pushed for the first time, Stitch will create the table in the destination in the specified integration schema.

During subsequent pushes, one of two things will happen depending on the destination being used:

1. **If the destination supports upserts**, Stitch will perform an update operation on applicable existing rows to overwrite the data.
2. **If the destination doesn’t support upserts**, Stitch will load the records in an append-only fashion. This means that existing records in the destination table will not be updated, and all records in subsequent pushes will be appended to the end of the table.

#### Structuring request body data

Refer to the [Structuring data for the Import API guide](https://help.qlik.com/en-US/stitch/developers/import-api/guides/structure-data-for-the-import-api) for instructions and examples.

##### Resource list

| **Request method** | POST |
| --- | --- |
| **Base URL** | The correct [base URL](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#base-urls) for your Stitch data pipeline region.<br><br>Your base URL is currently set to: `` |
| **Resource URL** | /v2/import/push |
| **Authorization** | Required. The request header must contain **Authorization** and your Import API access token. |
| **Request header** | The request header must contain the following:<br><br><ul> <li> <p><strong>Authorization</strong>: Must specify Bearer Auth, e.g. <code>Bearer: &lt;ACCESS_TOKEN&gt;</code></p> </li> <li> <p><strong>Content-Type</strong>: Must specify one of the following:</p> <ul> <li><code>application/json</code> - If using JSON</li> <li><code>application/transit+json</code> - If using Transit</li> </ul> </li></ul><br><br>See the **Request** tab below for example requests. |
| **Request body** | The request body must be valid JSON or Transit and contain the [required arguments](https://help.qlik.com/en-US/stitch/developers/import-api/api#push-data--arguments).<br><br>Additionally, the request body should provide an array (batch) of records to be inserted into the pipeline that adhere to the following:<br><br><ul> <li> <p>Must contain all <a href="https://help.qlik.com/en-US/stitch/integrations/import-api/faq#push-data--arguments">required arguments</a>.</p> </li> <li> <p>Cannot exceed 20MB in size.</p> </li> <li> <p>Each <code>data</code> object in the request body must contain between 1 and 20,000 records.</p> </li> <li> <p>Each <code>data</code> object in the request body cannot exceed 10,000 individual data points.</p> </li> <li> <p>Must contain a valid <code>client_id</code>. Each record in the request body must have the same <code>client_id</code>.</p> </li> <li> <p>Must be an array (batch) of records. The root cannot be an object.</p> </li></ul> |
| **Response format** | Whether the request succeeds or fails, the API will return JSON. |
| **Errors** | See the **Errors** tab, below. |

##### Arguments

This endpoint accepts the following parameters:

| **client\_id**<br><br><br><br>INTEGER<br><br><br><br><br><br><br><br><br><br><br>REQUIRED | The Stitch client ID associated with your Stitch account.<br><br>To locate your client ID, sign into your Stitch account and look at the URL. The client ID is the four to six-digit number between `client` and `pipeline` in the URL.<br><br>For example: If the URL is `https://app.stitchdata.com/v2/client/7723/pipeline/connections`, the client ID would be `7723`.<br><br>**Note**: This must be the same for every record in the request body. |
| --- | --- |
| **table\_name**<br><br><br><br>STRING<br><br><br><br><br><br><br><br><br><br><br>REQUIRED | The name of the destination table the data is being pushed to. Table names must be unique in each destination schema, or loading issues will occur.<br><br>A single request can push data to multiple tables.<br><br>**Note**: The number of characters in the table name should be within the destination’s allowed limits or data will rejected. |
| **sequence**<br><br><br><br>INTEGER<br><br><br><br><br><br><br><br><br><br><br>REQUIRED | An integer that tells the Import API the order in which data points in the request body should be considered for loading. This data will be stored in the destination table in the `_sdc_sequence` column.<br><br>In other Stitch integrations, Stitch uses a Unix epoch (in milliseconds) as the value for this property.<br><br>**Note**: This value cannot exceed the maximum of `9223372036854775807`. |
| **action**<br><br><br><br>STRING<br><br><br><br><br><br><br><br><br><br><br>REQUIRED | This will always be `upsert`. |
| **key\_names**<br><br><br><br>ARRAY<br><br><br><br><br><br><br><br><br><br><br>REQUIRED | An array of strings representing the Primary Key fields in the destination table.<br><br><ul> <li>All fields defined as Primary Keys must be present in the <code>data</code> object and their value cannot be <code>null</code></li> <li>If a Primary Key is a string, its value must be less than 256 characters</li> <li>Primary Key fields must be top-level fields in the table. For example: When sending JSON, a Primary Key field cannot be contained in an object or an array.</li></ul> |
| **data**<br><br><br><br>OBJECT<br><br><br><br><br><br><br><br><br><br><br>REQUIRED | An object representing a record to be pushed into the destination table.<br><br><ul> <li>All fields included in <code>key_names</code> must be included and their values cannot be <code>null</code></li> <li>The maximum number of data points per <code>data</code> object is 10,000</li> <li>If a Primary Key is a string, its value must be less than 256 characters</li></ul><br><br>Refer to the [Structuring data for the Import API guide](https://help.qlik.com/en-US/stitch/developers/import-api/guides/structure-data-for-the-import-api) for instructions and examples. |

##### Returns

If successful, the API will return a `2xx` status and a [Batch Status object](https://help.qlik.com/en-US/stitch/integrations/import-api/faq):

* `201` - The request was accepted and will be processed later. New data will be added once the request is processed.

* `202` - The request was accepted, but cannot currently be processed due to an internal error. Data will be automatically re-processed.

* Request
* Response
* Errors

**Requests for POST /v2/import/push**

```

            Pushing a single record for a single table
        
```

```
curl -X "POST" "https://api.stitchdata.com/v2/import/push" \
     -H 'Authorization: Bearer [ACCESS_TOKEN]' \
     -H 'Content-Type: application/json' \
     -d \
'[
   {
      "client_id":7723,
      "table_name":"customers",
      "sequence":1565880017,
      "data":{
         "id":1,
         "name":"Finn"
      },
      "key_names":[
         "id"
      ],
      "action":"upsert"
   }
]'
```

```

            Pushing multiple records for a single table
        
```

```
curl -X "POST" "https://api.stitchdata.com/v2/import/push" \
     -H 'Authorization: Bearer [ACCESS_TOKEN]' \
     -H 'Content-Type: application/json' \
     -d \
'[
   {
      "client_id":7723,
      "table_name":"customers",
      "sequence":1565880017,
      "data":{
         "id":4,
         "name":"BMO"
      },
      "key_names":[
         "id"
      ],
      "action":"upsert"
   },
   {
      "client_id":7723,
      "table_name":"customers",
      "sequence":1565838645,
      "data":{
         "id":5,
         "name":"Ice King"
      },
      "key_names":[
         "id"
      ],
      "action":"upsert"
   }
]'
```

```

            Pushing records for multiple tables
        
```

```
curl -X "POST" "https://api.stitchdata.com/v2/import/push" \
     -H 'Authorization: Bearer [ACCESS_TOKEN]' \
     -H 'Content-Type: application/json' \
     -d \
'[
   {
      "client_id":7723,
      "table_name":"customers",
      "sequence":1565880017,
      "data":{
         "id":4,
         "name":"BMO"
      },
      "key_names":[
         "id"
      ],
      "action":"upsert"
   },
   {
      "client_id":7723,
      "table_name":"orders",
      "sequence":1565838645,
      "data":{
         "order_id":561,
         "customer_id":4
      },
      "key_names":[
         "order_id"
      ],
      "action":"upsert"
   }
]'
```

**Responses for POST /v2/import/push**

```

            
        
```

```

{
  "status": "OK",
  "message": "Batch Accepted!"
}
```

```

            
        
```

```

{
  "status": "Accepted",
  "message": "The batch is queued to be processed."
}
```

| **Code** | **Condition** | **Response body** |
| --- | --- | --- |
| **400** | Request body is not an array | ```<br>{<br>"status": "ERROR",<br>"message": "An array of records is expected"<br>}<br>``` |
| **400** | Request body is malformed | ```<br>{<br>"status": "ERROR",<br>"message": "Malformed json in the body!",<br>"error": "Unexpected character (']' (code 93)): expected a value\n at [Source: java.io.StringReader@796a657e; line: 16, column: 2]",<br>"input": null<br>}<br>``` |
| **401** | Base URL doesn’t match account region | ```<br>{<br>"message": "Invalid region."<br>}<br>``` |
| **401** | `client_id` missing from request body | ```<br>{<br>"status": "ERROR",<br>"error": "Not Authenticated.",<br>"errors": null<br>}<br>``` |
| **401** | Integration is paused or has been deleted | ```<br>{<br>"error": "Forbidden",<br>"errors": {<br>"error": "Connection is not active."<br>}<br>}<br>``` |
| **403** | `client_id` and access token mismatch | ```<br>{<br>"status": "ERROR",<br>"error": "Forbidden",<br>"errors": {<br>"error": "Access token is not associated with this client."<br>}<br>}<br>``` |
| **405** | Unsupported method | `Method not allowed.` |
| **413** | Request body exceeds 20MB | ```<br>{<br>"status": "ERROR",<br>"message": "Request rejected: request size (<BYTE>s bytes) exceeds the maximum"<br>}<br>``` |
| **415** | Unsupported content type | ```<br>{<br>"status": "ERROR",<br>"message": "Unsupported content-type application/<TYPE>. Please send application/json or application/transit+json"<br>}<br>``` |
| **422** | Multiple client IDs in request | ```<br>{<br>"status": "ERROR",<br>"error": "Request cannot be processed; see errors.",<br>"errors": [<br>{<br>"reason": "The batch contains data points for multiple clients. Only client_id <CLIENT_ID> is allowed"<br>}<br>]<br>}<br>``` |
| **422** | Required argument is missing or blank | ```<br>{<br>"status": "ERROR",<br>"error": "Request cannot be processed; see errors.",<br>"errors": [<br>{<br>"<REQUIRED_ARGUMENT_NAME>": {<br>"table_name": [<br>"can't be blank"<br>]<br>}<br>}<br>]<br>}<br>``` |
| **422** | Required argument is incorrectly typed | ```<br>{<br>"status": "ERROR",<br>"error": "Request cannot be processed; see errors.",<br>"errors": [<br>{<br>"reason": {<br>"sequence": [<br>"should be an integer",<br>"should be a number"<br>]<br>}<br>}<br>]<br>}<br>``` |
| **422** | `data` must be typed as an object | ```<br>{<br>"status": "ERROR",<br>"error": "Request cannot be processed; see errors.",<br>"errors": [<br>{<br>"reason": {<br>"data": [<br>"data must be an object"<br>]<br>}<br>}<br>]<br>}<br>``` |
| **422** | `data` must include fields in `key_names` | ```<br>{<br>"status": "ERROR",<br>"error": "Request cannot be processed; see errors.",<br>"errors": [<br>{<br>"reason": {<br>"data": [<br>"data must include keys"<br>]<br>}<br>}<br>]<br>}<br>``` |
| **422** | Key values in `data` cannot be null | ```<br>{<br>"status": "ERROR",<br>"error": "Request cannot be processed; see errors.",<br>"errors": [<br>{<br>"reason": {<br>"data": [<br>"keys cannot not be null in data"<br>]<br>}<br>}<br>]<br>}<br>``` |
| **422** | Key names not provided | ```<br>{<br>"status": "ERROR",<br>"error": "Request cannot be processed; see errors.",<br>"errors": [<br>{<br>"reason": {<br>"key_names": [<br>"can't be blank"<br>],<br>"key_properties": [<br>"unknown key"<br>]<br>}<br>}<br>]<br>}<br>``` |
| **422** | String values in key fields cannot exceed 1,024 characters | ```<br>{<br>"status": "ERROR",<br>"error": "Request cannot be processed; see errors.",<br>"errors": [<br>{<br>"reason": {<br>"data": [<br>"String keys cannot be longer than 1024 characters"<br>]<br>}<br>}<br>]<br>}<br>``` |

## Data Structures

| OBJECT | **[Batch Status](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#batch-status-object)** | A Batch Status object provides information about the validation and acceptance status of a batch of data in a request body. **Note**: This object is only returned if the request body complies with the endpoint’s requirements. |
| --- | --- | --- |
| OBJECT | **[Error](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#error-object)** | An Error object provides information about the reason a request resulted in an error response from the Import API. |
| OBJECT | **[Error Reason](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#error-reason-object)** | Contained in an [Error](https://help.qlik.com/en-US/stitch/integrations/import-api/faq) object, the Error Reason object contains additional details about the reason a request resulted in an error response. |
| OBJECT | **[Message](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#message-object)** | A Message object contains information about a record to be upserted into a table. |
| OBJECT | **[Schema](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#schema-object)** | A Schema object contains a valid JSON schema describing the record(s) in a [Message object’s](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#message-object) `data` property.<br><br>Refer to the [JSON schema](https://json-schema.org/) docs for more info about JSON schemas. |

OBJECT

#### The Batch Status object

A Batch Status object provides information about the validation and acceptance status of a batch of data in a request body. **Note**: This object is only returned if the request body complies with the endpoint’s requirements.

| **status**<br><br><br><br>STRING | The batch status. Possible values are:<br><br><ul> <li><code>OK</code> - Corresponds to a <code>201 Created</code> response code if using the <a href="https://help.qlik.com/en-US/stitch/integrations/import-api/faq#push-data">Push</a> endpoint, or a <code>200 OK</code> response code if using the <a href="https://help.qlik.com/en-US/stitch/integrations/import-api/faq#validate-request">Validate</a> endpoint</li> <li><code>Accepted</code> - Corresponds to a <code>202 Accepted</code> response code</li></ul> |
| --- | --- |
| **message**<br><br><br><br>STRING | A message describing the current status of the batch. |

#### Example object

* Validate - 200 response
* Push - 201 response
* Push - 202 response

```

```

```
{
  "status": "OK",
  "message": "Batch is valid!"
}
```

```

```

```
{
  "status": "OK",
  "message": "Batch Accepted!"
}
```

```

```

```
{
  "status": "Accepted",
  "message": "The batch is queued to be processed."
}
```

OBJECT

#### The Error Reason object

Contained in an [Error](https://help.qlik.com/en-US/stitch/integrations/import-api/faq) object, the Error Reason object contains additional details about the reason a request resulted in an error response.

| **reason**<br><br><br><br>STRING, OBJECT | A string or an object describing the reason for the error.<br><br>When an object, the structure of this object is `"[field_name]": ["error_reason"]`, where `field_name` is the name of the argument that caused the error, and `error_reason` is an array of strings describing the reason for the error.<br><br>For example: `"data": ["data must include keys"]` |
| --- | --- |

#### Example object

* With reason as a string
* With reason as an object

```

```

```
{
  "status": "ERROR",
  "error": "Request cannot be processed; see errors.",
  "errors": [
    {
      "reason": "The batch contains data points for multiple clients. Only client_id <CLIENT_ID> is allowed"
    }
  ]
}
```

```

```

```
{
  "status": "ERROR",
  "error": "Request cannot be processed; see errors.",
  "errors": [
    {
      "reason": {
        "data": [
          "data must include keys"
        ]
      }
    }
  ]
}
```

OBJECT

#### The Error object

An Error object provides information about the reason a request resulted in an error response from the Import API.

| **status**<br><br><br><br>STRING | This will always be `ERROR`. |
| --- | --- |
| **message**<br><br><br><br>STRING | A message describing the error. |
| **error**<br><br><br><br>STRING | The reason for the error. |
| **errors**<br><br><br><br>ARRAY<br><br><br>([ERROR REASON](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#error-reason-object)) | An array of [error reason objects](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#error-reason-object) that describe the properties causing the error. |

#### Example object

* With error reason object
* Without error reason object

```

```

```
{
  "status": "ERROR",
  "error": "Request cannot be processed; see errors.",
  "errors": [
    {
      "reason": {
        "data": [
          "data must include keys"
        ]
      }
    }
  ]
}
```

```

```

```
{
  "status": "ERROR",
  "message": "An array of records is expected"
}
```

OBJECT

#### The Message object

A Message object contains information about a record to be upserted into a table.

| **action**<br><br><br><br>STRING | This will always be `upsert`. |
| --- | --- |
| **sequence**<br><br><br><br>INTEGER | An integer that tells the Import API the order in which data points in the request body should be considered for loading. This data will be stored in the destination table in the `_sdc_sequence` column.<br><br>In other Stitch integrations, Stitch uses a Unix epoch (in milliseconds) as the value for this property.<br><br>**Note**: This value cannot exceed the maximum of `9223372036854775807`. |
| **data**<br><br><br><br>OBJECT | The record to be upserted into a table. The record data must conform to the JSON schema contained in the request’s [Schema object](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#schema-object). |

#### Example object

```

```

```
{
  "action": "upsert",
  "sequence": 1574796577000,
  "data": {
    "id": 1,
    "name": "Finn",
    "age": 16,
    "has_magic": false
  }
}
```

OBJECT

#### The Schema object

A Schema object contains a valid JSON schema describing the record(s) in a [Message object’s](https://help.qlik.com/en-US/stitch/integrations/import-api/faq#message-object) `data` property.

Refer to the [JSON schema](https://json-schema.org/) docs for more info about JSON schemas.

| **properties**<br><br><br><br>OBJECT | The JSON schema that records in the `data` property must conform to. |
| --- | --- |

#### Example object

```

```

```
{
   "schema":{
      "properties":{
         "id":{
            "type":"integer"
         },
         "name":{
            "type":"string"
         },
         "age":{
            "type":"number"
         },
         "has_magic":{
            "type":"boolean"
         }
      }
   }
}
```