Create Trade Partners & Locations
Creates one or more standard locations together with their associated trade-partner information. Vessel-specific properties are documented in the separate Vessel API specification.
curl -X POST "https://connect.wholechain.com/Integration/Locations" \
-H "Content-Type: application/json" \
-H "X-API-KEY: example_string" \
-d '{
"Locations": [
{
"id": "OCEANIC-PLANT-001",
"Details": {
"TradePartner": {
"Id": "OCEANIC-EXPORTS",
"Name": "Oceanic Exports",
"ConnectionType": "SUPPLIER"
},
"Name": "Oceanic Processing Plant",
"Gln": "9506000140445",
"Extension": "SomeExtension",
"Duns": "123456789",
"ContactInformation": {
"Name": "Contact Name",
"Phone": "+1234567890",
"Email": "contact@example.com"
},
"Address": {
"City": "City Name",
"State": "State Name",
"Country": "Country Name",
"AddressLine1": "123 Main St",
"AddressLine2": "Building 4",
"PostalCode": "12345",
"GeoCoordinates": {
"Latitude": 12.345678,
"Longitude": 98.765432
},
"DisplayAddress": "123 Main St, City Name, State Name, Country Name, 12345"
},
"licenseNumber": "LIC-12345",
"locationGroup": {
"identifier": "GROUP-001",
"name": "Processing Plants",
"description": "Primary processing plant group"
},
"customData": [
{
"name": "Facility Type",
"namespace": "custom",
"value": "Processing"
}
]
}
}
]
}'
import requests
import json
url = "https://connect.wholechain.com/Integration/Locations"
headers = {
"Content-Type": "application/json",
"X-API-KEY": "example_string"
}
data = {
"Locations": [
{
"id": "OCEANIC-PLANT-001",
"Details": {
"TradePartner": {
"Id": "OCEANIC-EXPORTS",
"Name": "Oceanic Exports",
"ConnectionType": "SUPPLIER"
},
"Name": "Oceanic Processing Plant",
"Gln": "9506000140445",
"Extension": "SomeExtension",
"Duns": "123456789",
"ContactInformation": {
"Name": "Contact Name",
"Phone": "+1234567890",
"Email": "contact@example.com"
},
"Address": {
"City": "City Name",
"State": "State Name",
"Country": "Country Name",
"AddressLine1": "123 Main St",
"AddressLine2": "Building 4",
"PostalCode": "12345",
"GeoCoordinates": {
"Latitude": 12.345678,
"Longitude": 98.765432
},
"DisplayAddress": "123 Main St, City Name, State Name, Country Name, 12345"
},
"licenseNumber": "LIC-12345",
"locationGroup": {
"identifier": "GROUP-001",
"name": "Processing Plants",
"description": "Primary processing plant group"
},
"customData": [
{
"name": "Facility Type",
"namespace": "custom",
"value": "Processing"
}
]
}
}
]
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
const response = await fetch("https://connect.wholechain.com/Integration/Locations", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-KEY": "example_string"
},
body: JSON.stringify({
"Locations": [
{
"id": "OCEANIC-PLANT-001",
"Details": {
"TradePartner": {
"Id": "OCEANIC-EXPORTS",
"Name": "Oceanic Exports",
"ConnectionType": "SUPPLIER"
},
"Name": "Oceanic Processing Plant",
"Gln": "9506000140445",
"Extension": "SomeExtension",
"Duns": "123456789",
"ContactInformation": {
"Name": "Contact Name",
"Phone": "+1234567890",
"Email": "contact@example.com"
},
"Address": {
"City": "City Name",
"State": "State Name",
"Country": "Country Name",
"AddressLine1": "123 Main St",
"AddressLine2": "Building 4",
"PostalCode": "12345",
"GeoCoordinates": {
"Latitude": 12.345678,
"Longitude": 98.765432
},
"DisplayAddress": "123 Main St, City Name, State Name, Country Name, 12345"
},
"licenseNumber": "LIC-12345",
"locationGroup": {
"identifier": "GROUP-001",
"name": "Processing Plants",
"description": "Primary processing plant group"
},
"customData": [
{
"name": "Facility Type",
"namespace": "custom",
"value": "Processing"
}
]
}
}
]
})
});
const data = await response.json();
console.log(data);
package main
import (
"fmt"
"net/http"
"bytes"
"encoding/json"
)
func main() {
data := []byte(`{
"Locations": [
{
"id": "OCEANIC-PLANT-001",
"Details": {
"TradePartner": {
"Id": "OCEANIC-EXPORTS",
"Name": "Oceanic Exports",
"ConnectionType": "SUPPLIER"
},
"Name": "Oceanic Processing Plant",
"Gln": "9506000140445",
"Extension": "SomeExtension",
"Duns": "123456789",
"ContactInformation": {
"Name": "Contact Name",
"Phone": "+1234567890",
"Email": "contact@example.com"
},
"Address": {
"City": "City Name",
"State": "State Name",
"Country": "Country Name",
"AddressLine1": "123 Main St",
"AddressLine2": "Building 4",
"PostalCode": "12345",
"GeoCoordinates": {
"Latitude": 12.345678,
"Longitude": 98.765432
},
"DisplayAddress": "123 Main St, City Name, State Name, Country Name, 12345"
},
"licenseNumber": "LIC-12345",
"locationGroup": {
"identifier": "GROUP-001",
"name": "Processing Plants",
"description": "Primary processing plant group"
},
"customData": [
{
"name": "Facility Type",
"namespace": "custom",
"value": "Processing"
}
]
}
}
]
}`)
req, err := http.NewRequest("POST", "https://connect.wholechain.com/Integration/Locations", bytes.NewBuffer(data))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-API-KEY", "example_string")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)
}
require 'net/http'
require 'json'
uri = URI('https://connect.wholechain.com/Integration/Locations')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Content-Type'] = 'application/json'
request['X-API-KEY'] = 'example_string'
request.body = '{
"Locations": [
{
"id": "OCEANIC-PLANT-001",
"Details": {
"TradePartner": {
"Id": "OCEANIC-EXPORTS",
"Name": "Oceanic Exports",
"ConnectionType": "SUPPLIER"
},
"Name": "Oceanic Processing Plant",
"Gln": "9506000140445",
"Extension": "SomeExtension",
"Duns": "123456789",
"ContactInformation": {
"Name": "Contact Name",
"Phone": "+1234567890",
"Email": "contact@example.com"
},
"Address": {
"City": "City Name",
"State": "State Name",
"Country": "Country Name",
"AddressLine1": "123 Main St",
"AddressLine2": "Building 4",
"PostalCode": "12345",
"GeoCoordinates": {
"Latitude": 12.345678,
"Longitude": 98.765432
},
"DisplayAddress": "123 Main St, City Name, State Name, Country Name, 12345"
},
"licenseNumber": "LIC-12345",
"locationGroup": {
"identifier": "GROUP-001",
"name": "Processing Plants",
"description": "Primary processing plant group"
},
"customData": [
{
"name": "Facility Type",
"namespace": "custom",
"value": "Processing"
}
]
}
}
]
}'
response = http.request(request)
puts response.body
{
"message": "Success",
"result": [
{
"id": "01a0d84d-7aba-76bd-97b7-c2309d6f9bd4",
"status": "Created"
}
],
"errors": [],
"validations": []
}
{
"message": "Success",
"result": [
{
"id": "01a0d84d-7aba-76bd-97b7-c2309d6f9bd4",
"status": "Skipped"
}
],
"errors": [],
"validations": []
}
{
"message": "Success",
"result": [
{
"id": "01a0d84d-7aba-76bd-97b7-c2309d6f9bd4",
"status": "Updated"
}
],
"errors": [],
"validations": []
}
{
"type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"errors": {
"Locations[0].Details.TradePartner": [
"The TradePartner field is required."
]
},
"traceId": "…"
}
{
"type": "https://tools.ietf.org/html/rfc4918#section-11.2",
"title": "Location name is required",
"status": 422,
"traceId": "…"
}
/Integration/Locations
Target server for requests. Edit to use your own host.
The media type of the request body
API key used to authenticate the request.
Required.
Request Preview
Response
Response will appear here after sending the request
Responses
Introduction
This API allows you to create a trade partner together with one or more associated locations in Wholechain.
A trade partner represents the organization associated with a location. It may represent:
- Your own organization
- A supplier
- A buyer or customer
A location represents a physical place associated with that organization, such as a:
- Processing plant
- Warehouse
- Distribution center
- Office
- Port
- Farm
- Supplier facility
- Customer facility
When creating a location, the TradePartner object defines both the organization the location belongs to and the relationship between that organization and your Wholechain account.
If the TradePartner.Id does not already exist, the trade partner can be created as part of the same request.
If the trade partner already exists, reuse its existing TradePartner.Id when creating additional locations for that organization.
Vessel locations use the same endpoint but contain additional vessel-specific information. See the separate Create a Vessel documentation.
How It Works
Each entry in the Locations array contains:
- A unique Location ID
- A
TradePartnerobject - A
ConnectionType - Location details
- Contact information
- Address or geographic information
The trade partner and location can therefore be created together in one request.
For example, in the following relationship:
Oceanic Exports
└── Oceanic Processing Plant
Important: Unique IDs
Both trade partners and locations require unique identifiers.
Trade Partner ID
TradePartner.Id uniquely identifies the organization.
Do not reuse the same TradePartner.Id for a different organization.
If several locations belong to the same organization, reuse the same TradePartner.Id.
Location ID
Every location must have its own unique id.
Do not reuse an existing Location ID for a different physical location.
For example:
TradePartner.Id: OCEANIC-EXPORTS
Location 1:
id: OCEANIC-PLANT-001
Location 2:
id: OCEANIC-PLANT-002
Both locations belong to OCEANIC-EXPORTS, but each physical location has its own ID.
Request Headers
| Header | Description | Example Value |
|---|---|---|
X-API-KEY | Your Wholechain API key. | <YOUR_API_KEY> |
Content-Type | Content type of the request. | application/json |
accept | Response content type. | */* |
Payload Structure
The request contains a Locations array.
Multiple locations can be created in a single request.
Each location contains:
- A unique location ID
- Trade partner information
- Connection type
- Location information
- Contact information
- Address or geographic information
- Optional license number, location group, and custom data
Location Object
| Column Name | Data Type | Description | Required |
|---|---|---|---|
id | STRING | Unique identifier for the location. This ID must not be reused for a different location. | Yes |
Details | OBJECT | Contains the trade partner and detailed location information. | Yes |
updateIfExists | BOOLEAN | If true and a location with this id already exists, the existing location is updated with these details. If omitted or false, the existing location is left unchanged and reported as Skipped. | No |
Details Object
| Column Name | Data Type | Description | Required |
|---|---|---|---|
TradePartner | OBJECT | Creates or identifies the trade partner associated with this location and defines its relationship to your account. | Yes |
Name | STRING | Name of the location. | Yes |
Gln | STRING | Global Location Number associated with the location, if applicable. | No |
Extension | STRING | Additional identifier or extension associated with the location. | No |
Duns | STRING | DUNS number associated with the location. Must contain 9 or 13 digits. | No |
ContactInformation | OBJECT | Contact information associated with the location. | No |
Address | OBJECT | Physical address or geographic information for the location. | Yes |
licenseNumber | STRING | License number associated with the location. | No |
locationGroup | OBJECT | Location group the location belongs to. See Location Group Object. | No |
customData | ARRAY | Custom location data as name/namespace/value entries. See Custom Data Object. | No |
licenseNumber, locationGroup, and customData are shown with the property names defined in the API schema.
Trade Partner Object
The TradePartner object represents the organization associated with the location.
It can be used to:
- Create a new trade partner together with a location.
- Associate a new location with an existing trade partner.
| Column Name | Data Type | Description | Required |
|---|---|---|---|
Id | STRING | Unique identifier for the trade partner. If the trade partner already exists, reuse its existing ID. | Yes |
Name | STRING | Name of the trade partner. | Yes |
ConnectionType | STRING | Defines the relationship between the trade partner and your Wholechain account. | Yes |
If multiple locations belong to the same trade partner, use the same TradePartner.Id and TradePartner.Name for each location.
For example:
{
"TradePartner": {
"Id": "OCEANIC-EXPORTS",
"Name": "Oceanic Exports",
"ConnectionType": "SUPPLIER"
}
}
Connection Type
ConnectionType defines the relationship between your Wholechain account and the trade partner.
Supported values are:
| Connection Type | Description |
|---|---|
SELF | The trade partner represents your own organization. |
SUPPLIER | The trade partner supplies products or materials to your organization. |
BUYER | The trade partner purchases products or materials from your organization. |
| OTHER | The trade partner purchases and sells products or materials from/to your organization. |
The connection type describes your business relationship with the trade partner, not the physical function of the location.
SELF
Use SELF when creating a trade partner representing your own organization or when creating locations belonging to your own organization.
{
"TradePartner": {
"Id": "MY-COMPANY",
"Name": "My Company",
"ConnectionType": "SELF"
}
}
You can then create multiple locations under the same trade partner:
MY-COMPANY
├── Amsterdam Warehouse
├── Rotterdam Distribution Center
└── Head Office
Each location has a different Location ID but uses the same TradePartner.Id.
SUPPLIER
Use SUPPLIER when the organization supplies products or materials to your business.
{
"TradePartner": {
"Id": "SUPPLIER-001",
"Name": "Oceanic Exports",
"ConnectionType": "SUPPLIER"
}
}
BUYER
Use BUYER when the organization purchases products or materials from your business.
{
"TradePartner": {
"Id": "BUYER-001",
"Name": "Seafood Retailer",
"ConnectionType": "BUYER"
}
}
Contact Information Object
| Column Name | Data Type | Description | Required |
|---|---|---|---|
Name | STRING | Name of the primary contact for the location. | Yes |
Phone | STRING | Contact phone number. | No |
Email | STRING | Contact email address. | No |
Address Object
| Column Name | Data Type | Description | Required |
|---|---|---|---|
City | STRING | City of the location. | Yes |
State | STRING | State, province, or region of the location. | No |
Country | STRING | Country of the location. | Yes |
AddressLine1 | STRING | Primary address line. | Yes |
AddressLine2 | STRING | Secondary address line, if applicable. | No |
PostalCode | STRING | Postal or ZIP code. | No |
GeoCoordinates | OBJECT | Latitude and longitude of the location. | Yes, if address details are not provided |
DisplayAddress | STRING | Formatted human-readable address. | No |
GeoCoordinates Object
| Column Name | Data Type | Description |
|---|---|---|
Latitude | DECIMAL | Latitude of the location. |
Longitude | DECIMAL | Longitude of the location. |
If a standard street address is unavailable, geographic coordinates can be used to identify the location.
Location Group Object
The locationGroup object has the same fields as the request body of Create a Location Group.
| Column Name | Data Type | Description | Required |
|---|---|---|---|
identifier | STRING | Your identifier for the location group. Used to assign the location to an existing group or to create a new one. | Yes |
name | STRING | Name of the location group. Send it when the identifier is new, so the new group gets a name. | No |
description | STRING | Description of the location group. | No |
Assigning a Location Group
- If
identifiermatches an existing location group, the location is assigned to it. - If
identifierdoesn't match an existing group, a new location group is created with theidentifier,name, anddescriptionyou send, and the location is assigned to it. identifieris required. AlocationGroupwith only anamereturns422with the titleIdentifier is required, and the location is not created.- When a location is updated with an existing group's
identifier, anynameordescriptionsent with it replaces the group's current values. See Update a Location / Trade Partner.
To manage location groups through the API, see Create a Location Group, Update a Location Group, and Delete a Location Group.
Custom Data Object
Each entry in the customData array has the following fields.
| Column Name | Data Type | Description | Required |
|---|---|---|---|
name | STRING | Name of the custom location field. | No |
namespace | STRING | Namespace used to identify the custom data field. | No |
value | STRING | Value associated with the custom location field. | No |
Each name must match a custom data element that already exists in your Wholechain account. Facility Type in the examples on this page is a placeholder.
If a customData name doesn't match an existing data element, the API returns 422 with the title Location custom data name was not found: <name>. The location can still be created, but without its custom data and location group. Check the location and send an update after fixing the name.
Example: Create a Trade Partner and Location
The following example creates the trade partner Oceanic Exports together with one processing location.
{
"Locations": [
{
"id": "OCEANIC-PLANT-001",
"Details": {
"TradePartner": {
"Id": "OCEANIC-EXPORTS",
"Name": "Oceanic Exports",
"ConnectionType": "SUPPLIER"
},
"Name": "Oceanic Processing Plant",
"Gln": "9506000140445",
"Extension": "SomeExtension",
"Duns": "123456789",
"ContactInformation": {
"Name": "Contact Name",
"Phone": "+1234567890",
"Email": "contact@example.com"
},
"Address": {
"City": "City Name",
"State": "State Name",
"Country": "Country Name",
"AddressLine1": "123 Main St",
"AddressLine2": "Building 4",
"PostalCode": "12345",
"GeoCoordinates": {
"Latitude": 12.345678,
"Longitude": 98.765432
},
"DisplayAddress": "123 Main St, City Name, State Name, Country Name, 12345"
},
"licenseNumber": "LIC-12345",
"locationGroup": {
"identifier": "GROUP-001",
"name": "Processing Plants",
"description": "Primary processing plant group"
},
"customData": [
{
"name": "Facility Type",
"namespace": "custom",
"value": "Processing"
}
]
}
}
]
}
This creates:
Trade Partner
Oceanic Exports
Id: OCEANIC-EXPORTS
ConnectionType: SUPPLIER
│
└── Location
Oceanic Processing Plant
Id: OCEANIC-PLANT-001
Example: Create Multiple Locations for the Same Trade Partner
If one trade partner has multiple physical locations, reuse the same trade partner information for each location.
{
"Locations": [
{
"Id": "OCEANIC-PLANT-001",
"Details": {
"TradePartner": {
"Id": "OCEANIC-EXPORTS",
"Name": "Oceanic Exports",
"ConnectionType": "SUPPLIER",
"Duns": "123456789"
},
"Name": "Oceanic Processing Plant 1",
"Gln": "9506000140445",
"Extension": "Plant1",
"DunsPlus4": "0001",
"ContactInformation": {
"Name": "Plant 1 Contact",
"Phone": "+1234567890",
"Email": "plant1@oceanicexports.com"
},
"Address": {
"City": "Cape Town",
"State": "Western Cape",
"Country": "South Africa",
"AddressLine1": "123 Processing Street",
"AddressLine2": "Building 1",
"PostalCode": "8001"
}
}
},
{
"Id": "OCEANIC-PLANT-002",
"Details": {
"TradePartner": {
"Id": "OCEANIC-EXPORTS",
"Name": "Oceanic Exports",
"ConnectionType": "SUPPLIER",
"Duns": "123456789"
},
"Name": "Oceanic Processing Plant 2",
"Gln": "9506000140446",
"Extension": "Plant2",
"DunsPlus4": "0002",
"ContactInformation": {
"Name": "Plant 2 Contact",
"Phone": "+1234567891",
"Email": "plant2@oceanicexports.com"
},
"Address": {
"City": "Cape Town",
"State": "Western Cape",
"Country": "South Africa",
"AddressLine1": "456 Processing Street",
"AddressLine2": "Building 2",
"PostalCode": "8002"
}
}
}
]
}
This creates the following structure:
Oceanic Exports
TradePartner.Id: OCEANIC-EXPORTS
│
├── Oceanic Processing Plant 1
│ id: OCEANIC-PLANT-001
│
└── Oceanic Processing Plant 2
id: OCEANIC-PLANT-002
OCEANIC-EXPORTS is reused because both locations belong to the same organization.
Each location has a different id because every physical location must have its own unique identifier.
Vessel-specific fields are not covered on this page. See Create a Vessel for vessel locations.
Response
200 — OK
The response contains one result entry per location in the request.
{
"message": "Success",
"result": [
{
"id": "<wholechain-location-id>",
"status": "Created"
}
],
"errors": [],
"validations": []
}
result[].id is the Wholechain ID of the location, not the id you sent. status is one of the following:
| Status | Meaning |
|---|---|
Created | A new location was created. |
Skipped | A location with this id already exists, and updateIfExists was not true. The existing location was not changed. |
Updated | A location with this id already exists, and updateIfExists was true. The existing location was updated. |
Error Responses
Errors are returned as a problem details object with type, title, status, and traceId.
| Status | Cause | Example title or error |
|---|---|---|
400 | The X-API-KEY header is missing. | The apiKey field is required. |
400 | TradePartner is missing, or TradePartner.Name is missing. | The TradePartner field is required. |
422 | The location id is missing. | Either Location ID or URN must be provided, but not both |
422 | Name is missing. | Location name is required |
422 | No address details and no GeoCoordinates. | Address components or GeoCoordinates are required |
422 | locationGroup has no identifier. | Identifier is required |
422 | A customData name doesn't match an existing data element. | Location custom data name was not found: <name>. |
Important Notes
- This API can create a trade partner and its associated location together.
- If a location with the same
idalready exists, it is skipped. SetupdateIfExiststotrueto update it instead. - Every trade partner must have a unique
TradePartner.Id. - Do not reuse a
TradePartner.Idfor a different organization. - Every location must have a unique
id. - Do not reuse a Location ID for a different physical location.
- If multiple locations belong to the same organization, reuse the same
TradePartner.Id. - Each individual location must still have its own unique Location ID.
ConnectionTypemust describe the relationship between the trade partner and your Wholechain account.- Use
SELFfor your own organization. - Use
SUPPLIERfor organizations that supply your business. - Use
BUYERfor organizations that purchase from your business. - If the trade partner already exists, reuse its existing
TradePartner.Idwhen adding another location. - If a physical address is unavailable,
GeoCoordinatescan be used to identify the location. licenseNumber,locationGroup, andcustomDataare optional. Location groups can be managed with the Location Group endpoints.locationGrouprequires anidentifier. A newidentifiercreates the group.customDatanames must match data elements that already exist in your account.