tanqoryExtCompaniesCreateFromCustomers
- Mutation
- Customers and B2B
Requires write_customers access scope. About access scopes
Sets up one company for each customer, in one transaction: the company is named after the customer's default address company, else the customer's name; its one location takes that name, the default address (shipping and billing, when it has a street and a country), the customer's phone and language, the checkout and payment terms of input.buyerExperienceConfiguration and, with copyTaxSettings, the customer's tax exemption; the customer becomes the main contact with the Location admin role there; with addPastOrders the customer's orders of no company location move to it. REQUIRED (no customer), LIMIT_REACHED (more than 250), RESOURCE_NOT_FOUND (a customer, field ["customerIds", i]; nothing is written), payment terms errors as companyLocationCreate. Requires write_customers access scope.
Arguments
| Argument | Type | Required | Default |
|---|---|---|---|
customerIds | [ID!]! | Required | |
input | TanqoryExtCompaniesFromCustomersInput | Optional |
Returns
TanqoryExtCompaniesFromCustomersPayload Return type of tanqoryExtCompaniesCreateFromCustomers.
| Field | Type | Description |
|---|---|---|
companies | [Company!] | The companies set up, in the order of |
userErrors | [BusinessCustomerUserError!]! | Problems with the input. Empty when the call succeeded. |
Example request
A starting point: required arguments as variables and a few fields of the result. Replace the placeholders.
Set STORE_ID and TANQORY_ACCESS_TOKEN in your environment first (Make your first API call).
curl -X POST "https://api.tanqory.com/admin/2026-10/stores/$STORE_ID/graphql" \
-H "Authorization: Bearer $TANQORY_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
--data '{"query":"mutation TanqoryExtCompaniesCreateFromCustomers($customerIds: [ID!]!) {\n tanqoryExtCompaniesCreateFromCustomers(customerIds: $customerIds) {\n companies { id }\n userErrors {\n code\n field\n message\n }\n }\n}","variables":{"customerIds":[]}}'// Node.js 18 or later (fetch is built in). Save as request.mjs and run: node request.mjs
const query = `mutation TanqoryExtCompaniesCreateFromCustomers(\$customerIds: [ID!]!) {
tanqoryExtCompaniesCreateFromCustomers(customerIds: \$customerIds) {
companies { id }
userErrors {
code
field
message
}
}
}`;
const variables = {
"customerIds": []
};
const res = await fetch(`https://api.tanqory.com/admin/2026-10/stores/${process.env.STORE_ID}/graphql`, {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + process.env.TANQORY_ACCESS_TOKEN,
'Content-Type': 'application/json',
},
body: JSON.stringify({ query, variables }),
});
console.log(res.status, JSON.stringify(await res.json(), null, 2));# Python 3, standard library only. Save as request.py and run: python3 request.py
import json, os, urllib.request
query = """mutation TanqoryExtCompaniesCreateFromCustomers($customerIds: [ID!]!) {
tanqoryExtCompaniesCreateFromCustomers(customerIds: $customerIds) {
companies { id }
userErrors {
code
field
message
}
}
}"""
variables = json.loads("""{
"customerIds": []
}""")
req = urllib.request.Request(
"https://api.tanqory.com/admin/2026-10/stores/" + os.environ["STORE_ID"] + "/graphql",
data=json.dumps({"query": query, "variables": variables}).encode(),
headers={
"Authorization": "Bearer " + os.environ["TANQORY_ACCESS_TOKEN"],
"Content-Type": "application/json",
},
)
with urllib.request.urlopen(req) as res:
print(res.status, json.dumps(json.load(res), indent=2))