Mutations
Mutations are used to create, update or delete objects in Bunny.
Building the mutation request is similar to building a query in the sense that you will construct a query and supply a set of input attributes. However, with mutations you can also control the type and fields that are returned once the mutation has completed.
For example, to create an account and then return the id and name of the new account your mutation will look like this.
mutation accountCreate ($attributes: AccountAttributes!) {
accountCreate (attributes: $attributes) {
account {
id
name
}
errors
}
}
You will also need to supply valid attributes for creating an account like this
{
"accountTypeId": "456123",
"industryId": "456123",
"employees": 123,
"annualRevenue": 123,
"name": "",
"billingStreet": "",
"billingCity": "",
"billingState": "",
"billingZip": "",
"billingCountry": "",
"billingEmail": "",
"shippingStreet": "",
"shippingCity": "",
"shippingState": "",
"shippingZip": "",
"shippingCountry": "",
"description": "",
"phone": "",
"fax": "",
"website": "",
"currencyId": "456123",
"groupId": "456123",
"netPaymentDays": 123,
"duns": "",
"ownerUserId": "456123"
}
To make the request simply combine the mutation query and attributes.
curl -XPOST 'https://<subdomain>.bunny.com/graphql' \
--header 'Authorization: Bearer <access_token>' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"mutation accountCreate ($attributes: AccountAttributes!) {\n accountCreate (attributes: $attributes) {\n account {\n id\n name\n }\n errors\n }\n}","variables":{"attributes":{"accountTypeId":0,"industryId":0,"employees":0,"annualRevenue":0,"name":"","billingStreet":"","billingCity":"","billingState":"","billingZip":"","billingCountry":"","billingEmail":"","shippingStreet":"","shippingCity":"","shippingState":"","shippingZip":"","shippingCountry":"","description":"","phone":"","fax":"","website":"","currencyId":0,"groupId":0,"netPaymentDays":0,"duns":"","ownerUserId":0}}}'
Last updated
Was this helpful?