Loading Data

How an inbound submit works, the 1000-record limit, and the responses a submit can return.

Inbound endpoints are how you send master and transactional data to GAINS. This page explains how a submit works, how large a batch can be, and the responses a submit can return. Every accepted batch creates an integration task, described in Integration Tasks.

How an inbound submit works

  1. You POST a batch of records to an inbound endpoint, for example POST /locations.
  2. GAINS Connect checks each record against the endpoint's rules. Each record is accepted or rejected on its own.
  3. If at least one record is accepted, GAINS Connect creates an integration task for the accepted records and answers at once with its TaskId. Records rejected at this point are listed in the same response and are not part of the task.
  4. GAINS loads the task's records at its next scheduled load for that kind of data. The task then reaches a final status that gives the record counts and lists any record GAINS refused while loading it.

A 202 or 207 response therefore means the records were accepted for loading, not that they are already in GAINS. Follow the task to know when they are.

Which endpoint takes which kind of data is listed in Inbound Subjects. Deletes work the same way; see Deleting Data.

Sending a batch

Every inbound endpoint takes a JSON array of records. A request may hold at most 1000 records. The limit counts the top-level records only: on endpoints whose records carry nested data, such as orders with LineItems, a request can hold 1000 orders, each with its own lines.

POST /api/v1/locations HTTP/1.1
Host: acme.gainsystems.com
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...
Content-Type: application/json
Idempotency-Key: 6f1c2b8e-3d4a-4f5b-9c7e-0a1b2c3d4e5f
[
  {
    "LocationCode": "CHI01",
    "Name": "Chicago DC",
    "Type": "DC",
    "City": "Chicago",
    "State": "IL",
    "Country": "US",
    "PostalCode": "60607",
    "CurrencyCode": "USD"
  },
  {
    "LocationCode": "DAL02",
    "Name": "Dallas DC",
    "Type": "DC",
    "ParentDefaultCode": "CHI01",
    "City": "Dallas",
    "State": "TX",
    "Country": "US",
    "PostalCode": "75201",
    "CurrencyCode": "USD"
  }
]

When every record is accepted, GAINS Connect answers 202 with the task:

{
  "Status": "Queued",
  "TaskId": "c2791b62-508f-4aaa-b011-3764ff4625ee"
}

Status is the task's first status: usually Queued or Received, and PendingReview for a SKU-location delete. What each means is in Task statuses. Keep the TaskId: it is how you follow the batch from here on.

Submit responses

StatusMeaningWhat to do
202 AcceptedEvery record was accepted. The body holds Status and TaskId.Follow the task.
207 Multi-StatusSome records were accepted and a task was created for them. The body also lists the rejected records under RejectedRecords.Follow the task, and correct and resend only the rejected records.
422 Unprocessable ContentNothing was accepted and no task was created.Correct the request and send it again.
429 Too Many RequestsGAINS Connect is still taking in earlier batches and did not accept this one. Nothing was saved.Wait, then send the same batch again; see The ingest backlog and 429.
400 Bad RequestThe request could not be read: malformed JSON, a field name the endpoint does not know, a value of the wrong JSON type, or a reused Idempotency-Key. Nothing was saved.Correct the request.

Statuses common to every endpoint, such as 401, 403 and 5xx, are described in Errors & Retries.

🚧

A 207 is a partial success

Treat 207 as "accepted, with exceptions", not as a failure. The accepted records are already in a task and will be loaded, so resending the whole batch would submit them twice.

A 207 carries the task's Status and TaskId and, under RejectedRecords, each rejected record with its reasons; see Rejections at submit.

A 422 comes in one of two forms. When every record failed its checks, the body has the same RejectedRecords list, with Status set to RejectedFailedProcessing and no TaskId. When the request itself is refused, for example because the array is empty or holds more than 1000 records, the body is a single Reason:

{
  "Reason": "The data provided exceeds the maximum constraint. Please submit a maximum of 1000 records."
}

How to read and act on RejectedRecords is described in Rejected Records.

Retrying

Whether to retry is in Errors & Retries, which key to resend with in Idempotency, and how to pace retries in Load Throughput & Retries.

Related


What’s Next

Did this page help you?