Manage company buyers
Prerequisites
- Merchant API key (
X-ApiKey) - Authenticated user session (JWT bearer token)
- User associated with a company account
Goals
- Add new buyers to a company (create or assign existing users)
- Update buyer details such as name, phone, and active status
- Remove buyers from the company
Architecture at a glance
- Authenticate company user →
createCompanyBuyer/assignCompanyBuyer/updateCompanyBuyer/deleteCompanyBuyer→ Verify viagetCompany
APIs used
- Merchant API:
https://merchantapi.geins.io/graphql
Step-by-step
Create a new buyer
Use createCompanyBuyer to add a completely new buyer to the company. The buyer's id is their email address, which also serves as their login identifier.
Request example
mutation createCompanyBuyer(
$buyer: CreateCompanyBuyerInputType!
$channelId: String
$languageId: String
$marketId: String
) {
createCompanyBuyer(
buyer: $buyer
channelId: $channelId
languageId: $languageId
marketId: $marketId
)
}
{
"Accept": "application/json",
"X-ApiKey": "{MERCHANT_API_KEY}",
"Authorization": "Bearer {JWT_TOKEN}"
}
{
"buyer": {
"id": "erik.johansson@acme.se",
"firstName": "Erik",
"lastName": "Johansson",
"phone": "+46701234567"
},
"channelId": "{CHANNEL_ID}",
"languageId": "{LANGUAGE_ID}",
"marketId": "{MARKET_ID}"
}
curl -X POST https://merchantapi.geins.io/graphql \
-H "Accept: application/json" \
-H "X-ApiKey: {MERCHANT_API_KEY}" \
-H "Authorization: Bearer {JWT_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"query":"mutation createCompanyBuyer($buyer:CreateCompanyBuyerInputType!,$channelId:String,$languageId:String,$marketId:String){createCompanyBuyer(buyer:$buyer,channelId:$channelId,languageId:$languageId,marketId:$marketId)}","variables":{"buyer":{"id":"erik.johansson@acme.se","firstName":"Erik","lastName":"Johansson","phone":"+46701234567"},"channelId":"{CHANNEL_ID}","languageId":"{LANGUAGE_ID}","marketId":"{MARKET_ID}"}}'
id field (email) is required. Fields firstName, lastName, phone, and active are optional. If active is omitted it defaults to true.Response example
200 OK{
"data": {
"createCompanyBuyer": true
}
}
Assign an existing user as buyer
Use assignCompanyBuyer to link an already-registered user to the company as a buyer. This is useful when the user already has an account but needs to be added to a company.
Request example
mutation assignCompanyBuyer(
$id: String!
$channelId: String
$languageId: String
$marketId: String
) {
assignCompanyBuyer(
id: $id
channelId: $channelId
languageId: $languageId
marketId: $marketId
)
}
{
"Accept": "application/json",
"X-ApiKey": "{MERCHANT_API_KEY}",
"Authorization": "Bearer {JWT_TOKEN}"
}
{
"id": "existing.user@acme.se",
"channelId": "{CHANNEL_ID}",
"languageId": "{LANGUAGE_ID}",
"marketId": "{MARKET_ID}"
}
curl -X POST https://merchantapi.geins.io/graphql \
-H "Accept: application/json" \
-H "X-ApiKey: {MERCHANT_API_KEY}" \
-H "Authorization: Bearer {JWT_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"query":"mutation assignCompanyBuyer($id:String!,$channelId:String,$languageId:String,$marketId:String){assignCompanyBuyer(id:$id,channelId:$channelId,languageId:$languageId,marketId:$marketId)}","variables":{"id":"existing.user@acme.se","channelId":"{CHANNEL_ID}","languageId":"{LANGUAGE_ID}","marketId":"{MARKET_ID}"}}'
id parameter is the email address of the existing user to assign. Use createCompanyBuyer instead if the user does not already have an account.Response example
200 OK{
"data": {
"assignCompanyBuyer": true
}
}
Update a buyer
Use updateCompanyBuyer to modify buyer details. Only provided fields are updated. Changing the id field reassigns the buyer to a new email/identifier.
Request example
mutation updateCompanyBuyer(
$id: String!
$buyer: UpdateCompanyBuyerInputType!
$channelId: String
$languageId: String
$marketId: String
) {
updateCompanyBuyer(
id: $id
buyer: $buyer
channelId: $channelId
languageId: $languageId
marketId: $marketId
)
}
{
"Accept": "application/json",
"X-ApiKey": "{MERCHANT_API_KEY}",
"Authorization": "Bearer {JWT_TOKEN}"
}
{
"id": "erik.johansson@acme.se",
"buyer": {
"phone": "+46709876543",
"active": false
},
"channelId": "{CHANNEL_ID}",
"languageId": "{LANGUAGE_ID}",
"marketId": "{MARKET_ID}"
}
curl -X POST https://merchantapi.geins.io/graphql \
-H "Accept: application/json" \
-H "X-ApiKey: {MERCHANT_API_KEY}" \
-H "Authorization: Bearer {JWT_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"query":"mutation updateCompanyBuyer($id:String!,$buyer:UpdateCompanyBuyerInputType!,$channelId:String,$languageId:String,$marketId:String){updateCompanyBuyer(id:$id,buyer:$buyer,channelId:$channelId,languageId:$languageId,marketId:$marketId)}","variables":{"id":"erik.johansson@acme.se","buyer":{"phone":"+46709876543","active":false},"channelId":"{CHANNEL_ID}","languageId":"{LANGUAGE_ID}","marketId":"{MARKET_ID}"}}'
UpdateCompanyBuyerInputType are optional. Setting active to false deactivates the buyer without removing them. To change the buyer's email, pass a new value in the id field inside the buyer input — this reassigns the buyer to the new email.Response example
200 OK{
"data": {
"updateCompanyBuyer": true
}
}
Remove a buyer
Use deleteCompanyBuyer to remove a buyer from the company. The id parameter is the buyer's email address.
Request example
mutation deleteCompanyBuyer(
$id: String!
$channelId: String
$languageId: String
$marketId: String
) {
deleteCompanyBuyer(
id: $id
channelId: $channelId
languageId: $languageId
marketId: $marketId
)
}
{
"Accept": "application/json",
"X-ApiKey": "{MERCHANT_API_KEY}",
"Authorization": "Bearer {JWT_TOKEN}"
}
{
"id": "erik.johansson@acme.se",
"channelId": "{CHANNEL_ID}",
"languageId": "{LANGUAGE_ID}",
"marketId": "{MARKET_ID}"
}
curl -X POST https://merchantapi.geins.io/graphql \
-H "Accept: application/json" \
-H "X-ApiKey: {MERCHANT_API_KEY}" \
-H "Authorization: Bearer {JWT_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"query":"mutation deleteCompanyBuyer($id:String!,$channelId:String,$languageId:String,$marketId:String){deleteCompanyBuyer(id:$id,channelId:$channelId,languageId:$languageId,marketId:$marketId)}","variables":{"id":"erik.johansson@acme.se","channelId":"{CHANNEL_ID}","languageId":"{LANGUAGE_ID}","marketId":"{MARKET_ID}"}}'
Response example
200 OK{
"data": {
"deleteCompanyBuyer": true
}
}
Options
Multi-market support
All mutations support optional parameters for multi-market functionality:
channelId: Target specific sales channelslanguageId: Set content languagemarketId: Target specific markets
Authenticated access
Authentication is required for all company buyer mutations. The API uses the JWT bearer token to identify the user's company membership and scope operations to that company. Without a valid token the request will fail with an authorization error.
Include the token in the Authorization header:
Authorization: Bearer {JWT_TOKEN}
Common pitfalls
- A buyer cannot remove themselves — The
deleteCompanyBuyermutation prevents users from deleting their own account. Another company member must perform the removal. createCompanyBuyervsassignCompanyBuyer— UsecreateCompanyBuyerwhen the person does not yet have an account. UseassignCompanyBuyerwhen you want to link an already-registered user to the company.- Changing buyer email via
updateCompanyBuyer— Passing a newidin thebuyerinput reassigns the buyer to that email. This changes their login identifier. - Deactivating vs removing — Setting
active: falseviaupdateCompanyBuyerdisables the buyer without deleting them, preserving their order history association. UsedeleteCompanyBuyeronly for permanent removal.