Invoke mappings
This functionality is available in a Stedi module. Contact us for details.
Once you create a mapping, you can use it to transform JSON into a custom shape.
Inbound - Mappings API
You can use webhooks to automatically send transaction processed events to any API endpoint. Then, you can use the Map Transaction Output endpoint to return the mapped output of the processed inbound transaction.
You can also call the Invoke Mapping API to transform JSON into a custom shape.
Outbound - Create Outbound Transaction
Call the Create Outbound Transaction endpoint with a mapping ID. Stedi uses the specified mapping to automatically transform your system’s data into Guide JSON before generating and delivering the EDI file.
Payload validation
By default, the Mappings API doesn’t validate incoming or transformed JSON.
When you enable strict validation mode, Mappings uses the source schema to validate the input JSON payload and the target schema to validate the outgoing JSON payload.
To enable strict validation mode, set the validation_mode
query parameter to strict
. The following example shows how to enable strict validation mode in your request.
Success and failure responses
- If the mapping is evaluated successfully and there are no validation failures, the body of the response is the mapped document.
- If the evaluation of the mapping expression fails, then validation of the input and the output is not applied, the response is a 400 error with the
mapping_failed
code and novalidation_errors
object. - If validation of the input or output payload fails, the response is a 400 error with the
validation_failed
code andvalidation_errors
object.
Example request
The following example shows a request to the Invoke Mapping API. The request body is the JSON document that you want to map.
The body of the response is the mapped document.
You must make a separate request to the API for each JSON document. Visit Concurrency for more details.
Send a compressed payload to the API
To send a gzip
compressed payload to the Mappings API, set the Content-Encoding
header to the value of gzip
. Mappings API currently only supports gzip
compression.
Note that the maximum document size limit is applied after decompressing the content of the payload. If the decompressed payload of a given request is larger than the maximum document size limit, the Mappings API will reject the request.
The following is an example written in TypeScript of creating mapping and sending a gzip
compressed payload to the /map
endpoint.
API concurrency
Mappings allows up to 200 concurrent requests, so if you need to map 200 documents or less, you can send them all at once. If you need to map more than 200 documents, you should make sure that you don’t exceed 1000 requests per second. Also keep in mind that there’s a maximum of one million requests per day.
If you make more requests than Mappings is able to handle, you will receive a 429 Too Many Requests
response.
- Keep track of how many outstanding requests you have. Don’t send any new requests if you have 200 or more.
- Keep track of how many total requests you’ve sent in a day and make sure it doesn’t exceed 1,000,000.
- Keep a timestamp for every successful response you receive. When sending a new request, first check the timestamp for 1000 requests ago. If it’s less than a second ago, wait until the second has passed before making a new request.
- If you receive a 429 Too Many Requests response, wait for one second before sending new requests. If you still get back 429 after waiting for one second, then wait for two seconds. If that’s not enough wait for four, then eight, etc.
- If you receive a 429 Too Many Requests response, add the document back into the list of documents that you need to map. Don’t resend the request immediately.
Was this page helpful?