Update a company
Less than to read
What you can update
You can update the following parameters of a company:
name
externalId
address
taxNumber
standardIndustrialCode
contactTelNo
contactEmail
For detailed information about these parameter go to the Onboarding and authentication API reference.
Each of these parameters supports the following operations:
add
– This adds a new value to the specified parameter.remove
– This removes the current value of the specified parameter.replace
– This replaces the current value of the specified parameter with the new one. Using this operation is the same as running aremove
followed by anadd
.
Prerequisites
To update a company, you need to know its companyId
parameter value and have a valid access token for the company. After you have completed onboarding, you should have the companyId
value and a valid access token.
For more information, go to the onboard a Sage application guide.
Configure and send a PATCH request
Send a PATCH request with the following headers and body.
Headers
PATCH /auth-v1/companies/{companyId} HTTP/1.1
Host: api-money.sage.com
Content-Type: application/json
Authorization: Bearer {access token}
-
{companyId}
– This is the unique ID of the company. -
Bearer {access token}
– This is the authorisation string for your request, where{access token}
is a valid token for the company.
Body
[
{
"op" : "replace",
"path" : "{parameter 1}",
"value" : "{new value}"
},
{
"op" : "replace",
"path" : "{parameter 2}",
"value" : "{new value}"
},
{
"op" : "replace",
"path" : "{parameter 3}",
"value" : "{new value}"
}
]
Where:
-
op
specifies the operation you want to perform on the parameter. To simplify the task, we use thereplace
operation. -
path
specifies the name of the parameter whose value you want to update. You can update as many parameters as you need to at a time. -
value
specifies the new parameter value you want to set.
Example requests
Update a single parameter
PATCH /auth-v1/companies/72fb2b54-8687-417e-a2b4-e59e2c7507d9 HTTP/1.1
Host: api-money.sage.com
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiJ.eyJjY1ZlcnNpb24iOiIyLjIuMC4wIiwib3JnYW5pc2F0aW9uSWQiOiI2M2FiZTdiYi1hYjJiLTRlMTktYmFlZC0xNmM5Y2JmZjBmMmEiLCJzb3VyY2VQcm9kdWN0Ijoic2FnZS5icmF6aWwub25lIiwia2lkIj25lIioiNa2la2lkI
[
{
"op" : "replace",
"path" : "/name",
"value" : "My company"
}
]
This request sets the value of the name
parameter to My company
. It updates the company whose unique ID is 72fb2b54-8687-417e-a2b4-e59e2c7507d9
.
Update company address
PATCH /auth-v1/companies/72fb2b54-8687-417e-a2b4-e59e2c7507d9 HTTP/1.1
Host: api-money.sage.com
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiJ.eyJjY1ZlcnNpb24iOiIyLjIuMC4wIiwib3JnYW5pc2F0aW9uSWQiOiI2M2FiZTdiYi1hYjJiLTRlMTktYmFlZC0xNmM5Y2JmZjBmMmEiLCJzb3VyY2VQcm9kdWN0Ijoic2FnZS5icmF6aWwub25lIiwia2lkIj25lIioiNa2la2lkI
[
{
"op" : "replace",
"path" : "/address/addressLine1",
"value" : "Address line 1"
},
{
"op" : "replace",
"path" : "/address/addressLine2",
"value" : "Address line 2"
},
{
"op" : "replace",
"path" : "/address/addressLine3",
"value" : "Address line 3"
},
{
"op" : "replace",
"path" : "/address/addressLine4",
"value" : "Address line 4"
},
{
"op" : "replace",
"path" : "/address/countrySubdivision",
"value" : "Country subdivision"
},
{
"op" : "replace",
"path" : "/address/postalCode",
"value" : "Postal code"
},
{
"op" : "replace",
"path" : "/address/country",
"value" : "UK"
}
]
This request updates the address of the company whose unique ID is 72fb2b54-8687-417e-a2b4-e59e2c7507d9
as follows:
-
Sets the value of the
addressLine1
parameter toAddress line 1
. -
Sets the value of the
addressLine2
parameter toAddress line 2
. -
Sets the value of the
addressLine3
parameter toAddress line 3
. -
Sets the value of the
addressLine4
parameter toAddress line 4
. -
Sets the value of the
countrySubdivision
parameter toCountry subdivision
. -
Sets the value of the
postalCode
parameter toPostal code
. -
Sets the value of the
country
parameter toUK
.