Manage company buyers
Prerequisites
- Merchant API key (
X-Api)Key - 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 →
create/Company Buyer assign/Company Buyer update/Company Buyer delete→ Verify viaCompany Buyer getCompany
APIs used
- Merchant API:
https://merchantapi.geins.io/graphql
Step-by-step
Create a new buyer
Use create 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 assign 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 update 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 delete 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:
channel: Target specific sales channelsId language: Set content languageId market: Target specific marketsId
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
deletemutation prevents users from deleting their own account. Another company member must perform the removal.Company Buyer createvsCompany Buyer assign— UseCompany Buyer createwhen the person does not yet have an account. UseCompany Buyer assignwhen you want to link an already-registered user to the company.Company Buyer - Changing buyer email via
update— Passing a newCompany Buyer idin thebuyerinput reassigns the buyer to that email. This changes their login identifier. - Deactivating vs removing — Setting
active: falseviaupdatedisables the buyer without deleting them, preserving their order history association. UseCompany Buyer deleteonly for permanent removal.Company Buyer