Skip to main content
POST
/
v1
/
templates
/
upsert
Upsert multiple templates
curl --request POST \
  --url https://api.sandbox.usenash.com/v1/templates/upsert \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "templates": [
    {
      "type": "DELIVERY_WINDOW",
      "deliveryWindowTemplatePayload": {
        "key": "value"
      },
      "shiftTemplatePayload": {
        "key": "value"
      },
      "externalId": "ext_01234567890123456789",
      "name": "Monday Delivery Window",
      "startDatetime": "2024-01-01T12:00:00",
      "endDatetime": "2024-01-01T12:00:00",
      "daysOfWeek": [
        "MONDAY",
        "TUESDAY"
      ],
      "generationFrequencyValue": 1,
      "generationFrequencyUnit": "DAY",
      "createInstancesUpToValue": 1,
      "createInstancesUpToUnit": "DAY",
      "overrideExistingInstances": true
    }
  ]
}
'
import requests

url = "https://api.sandbox.usenash.com/v1/templates/upsert"

payload = { "templates": [
        {
            "type": "DELIVERY_WINDOW",
            "deliveryWindowTemplatePayload": { "key": "value" },
            "shiftTemplatePayload": { "key": "value" },
            "externalId": "ext_01234567890123456789",
            "name": "Monday Delivery Window",
            "startDatetime": "2024-01-01T12:00:00",
            "endDatetime": "2024-01-01T12:00:00",
            "daysOfWeek": ["MONDAY", "TUESDAY"],
            "generationFrequencyValue": 1,
            "generationFrequencyUnit": "DAY",
            "createInstancesUpToValue": 1,
            "createInstancesUpToUnit": "DAY",
            "overrideExistingInstances": True
        }
    ] }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    templates: [
      {
        type: 'DELIVERY_WINDOW',
        deliveryWindowTemplatePayload: {key: 'value'},
        shiftTemplatePayload: {key: 'value'},
        externalId: 'ext_01234567890123456789',
        name: 'Monday Delivery Window',
        startDatetime: '2024-01-01T12:00:00',
        endDatetime: '2024-01-01T12:00:00',
        daysOfWeek: ['MONDAY', 'TUESDAY'],
        generationFrequencyValue: 1,
        generationFrequencyUnit: 'DAY',
        createInstancesUpToValue: 1,
        createInstancesUpToUnit: 'DAY',
        overrideExistingInstances: true
      }
    ]
  })
};

fetch('https://api.sandbox.usenash.com/v1/templates/upsert', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.sandbox.usenash.com/v1/templates/upsert",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'templates' => [
        [
                'type' => 'DELIVERY_WINDOW',
                'deliveryWindowTemplatePayload' => [
                                'key' => 'value'
                ],
                'shiftTemplatePayload' => [
                                'key' => 'value'
                ],
                'externalId' => 'ext_01234567890123456789',
                'name' => 'Monday Delivery Window',
                'startDatetime' => '2024-01-01T12:00:00',
                'endDatetime' => '2024-01-01T12:00:00',
                'daysOfWeek' => [
                                'MONDAY',
                                'TUESDAY'
                ],
                'generationFrequencyValue' => 1,
                'generationFrequencyUnit' => 'DAY',
                'createInstancesUpToValue' => 1,
                'createInstancesUpToUnit' => 'DAY',
                'overrideExistingInstances' => true
        ]
    ]
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.sandbox.usenash.com/v1/templates/upsert"

	payload := strings.NewReader("{\n  \"templates\": [\n    {\n      \"type\": \"DELIVERY_WINDOW\",\n      \"deliveryWindowTemplatePayload\": {\n        \"key\": \"value\"\n      },\n      \"shiftTemplatePayload\": {\n        \"key\": \"value\"\n      },\n      \"externalId\": \"ext_01234567890123456789\",\n      \"name\": \"Monday Delivery Window\",\n      \"startDatetime\": \"2024-01-01T12:00:00\",\n      \"endDatetime\": \"2024-01-01T12:00:00\",\n      \"daysOfWeek\": [\n        \"MONDAY\",\n        \"TUESDAY\"\n      ],\n      \"generationFrequencyValue\": 1,\n      \"generationFrequencyUnit\": \"DAY\",\n      \"createInstancesUpToValue\": 1,\n      \"createInstancesUpToUnit\": \"DAY\",\n      \"overrideExistingInstances\": true\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.sandbox.usenash.com/v1/templates/upsert")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"templates\": [\n    {\n      \"type\": \"DELIVERY_WINDOW\",\n      \"deliveryWindowTemplatePayload\": {\n        \"key\": \"value\"\n      },\n      \"shiftTemplatePayload\": {\n        \"key\": \"value\"\n      },\n      \"externalId\": \"ext_01234567890123456789\",\n      \"name\": \"Monday Delivery Window\",\n      \"startDatetime\": \"2024-01-01T12:00:00\",\n      \"endDatetime\": \"2024-01-01T12:00:00\",\n      \"daysOfWeek\": [\n        \"MONDAY\",\n        \"TUESDAY\"\n      ],\n      \"generationFrequencyValue\": 1,\n      \"generationFrequencyUnit\": \"DAY\",\n      \"createInstancesUpToValue\": 1,\n      \"createInstancesUpToUnit\": \"DAY\",\n      \"overrideExistingInstances\": true\n    }\n  ]\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.sandbox.usenash.com/v1/templates/upsert")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"templates\": [\n    {\n      \"type\": \"DELIVERY_WINDOW\",\n      \"deliveryWindowTemplatePayload\": {\n        \"key\": \"value\"\n      },\n      \"shiftTemplatePayload\": {\n        \"key\": \"value\"\n      },\n      \"externalId\": \"ext_01234567890123456789\",\n      \"name\": \"Monday Delivery Window\",\n      \"startDatetime\": \"2024-01-01T12:00:00\",\n      \"endDatetime\": \"2024-01-01T12:00:00\",\n      \"daysOfWeek\": [\n        \"MONDAY\",\n        \"TUESDAY\"\n      ],\n      \"generationFrequencyValue\": 1,\n      \"generationFrequencyUnit\": \"DAY\",\n      \"createInstancesUpToValue\": 1,\n      \"createInstancesUpToUnit\": \"DAY\",\n      \"overrideExistingInstances\": true\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
{
  "templates": [
    {
      "id": "tpl_01234567890123456789",
      "type": "DELIVERY_WINDOW",
      "payload": {},
      "externalId": "<string>",
      "name": "<string>",
      "startDatetime": "2024-01-01T12:00:00",
      "endDatetime": "2024-01-01T12:00:00",
      "daysOfWeek": [
        "MONDAY",
        "TUESDAY"
      ],
      "generationFrequencyValue": 1,
      "generationFrequencyUnit": "DAY",
      "createInstancesUpToValue": 1,
      "createInstancesUpToUnit": "DAY",
      "overrideExistingInstances": true
    }
  ]
}
[
  {
    "error": {
      "code": "<string>",
      "message": "<string>",
      "details": {}
    },
    "response_status": "<string>",
    "RequestID": "<string>"
  }
]

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Expected payload for creating multiple templates.

templates
CreateTemplateInputSerializer · object[]
required

Response

OK

Response for a list of templates.

templates
TemplateOutput · object[]
required