company query
The company
query returns details about the user's company. The request must include the customer token of a company user.
A company structure can contain multiple levels of teams, with company users assigned at each level. To query on a company structure, specify fragments on the Customer
and CompanyTeam
objects. The application returns a union of these objects. Specify the __typename
attribute to distinguish the object types in the response.
The CompanyCredit
output object contains the company's available_credit
and outstanding_balance
values. These values cannot be changed with a mutation. The available_credit
amount is the sum of the credit limit and the outstanding balance. If the company has exceeded the credit limit, the amount is as a negative value. The outstanding_balance
amount is the amount reimbursed, less the total due from all orders placed using the Payment on Account payment method. The amount can be a positive or negative value.
This query requires a valid customer authentication token.
Syntax
{company: {Company}}
Reference
The company
reference provides detailed information about the types and fields defined in this query.
Example usage
Return information about a newly-created company
The following call returns basic information about the customer's company.
Request:
Copied to your clipboardquery{company{company_admin {firstnamelastname}idlegal_address {streetcityregion {region_idregion_code}postcodecountry_codetelephone}legal_namename}}
Response:
Copied to your clipboard{"data": {"company": {"company_admin": {"firstname": "Taina","lastname": "Garofalo","email": "tgarofalo@example.com"},"email": "tgarofalo@example.com","id": "MQ==","legal_address": {"street": ["265 Cambridge Ave"],"city": "Palo Alto","region": {"region_id": 12,"region_code": "CA"},"postcode": "94306","country_code": "US","telephone": "555 867-5309"},"legal_name": "TestCo Inc.","name": "TestCo"}}}
Return the company structure
The following query returns the customer's company structure.
Request:
Copied to your clipboardquery{company{idnamestructure{items {entity {__typename... on Customer {firstnamelastname}... on CompanyTeam {namedescriptionid}}}}}}
Response:
Copied to your clipboard{"data": {"company": {"id": "Ng==","name": "TestCo2","structure": {"items": [{"entity": {"__typename": "Customer","firstname": "Taina","lastname": "Garofalo","email": "donadmin@example.com"}},{"entity": {"__typename": "CompanyTeam","name": "Y Team","description": "Y Team description","id": "Ng=="}},{"entity": {"__typename": "Customer","firstname": "B","lastname": "BB","email": "bbb@example.com"}},{"entity": {"__typename": "CompanyTeam","name": "X team","description": "X team description","id": "Nw=="}},{"entity": {"__typename": "Customer","firstname": "A","lastname": "AA","email": "aa@example.com"}},{"entity": {"__typename": "CompanyTeam","name": "Z Team","description": "Z team description","id": "NQ=="}},{"entity": {"__typename": "Customer","firstname": "C","lastname": "CC","email": "ccc@example.com"}}]}}}}
Return the company credit history
The following query returns a company's current company credit balance as well as a record of all company credit events.
Request:
Copied to your clipboardquery{company{nameidcredit {available_credit {valuecurrency}credit_limit {valuecurrency}outstanding_balance {valuecurrency}}credit_history{items {datetypeamount {valuecurrency}balance {outstanding_balance {valuecurrency}available_credit {valuecurrency}credit_limit {valuecurrency}}}}payment_methods}}
Response:
Copied to your clipboard{"data": {"company": {"name": "TestCo","id": "MQ==","credit": {"available_credit": {"value": 436,"currency": "USD"},"credit_limit": {"value": 500,"currency": "USD"},"outstanding_balance": {"value": -64,"currency": "USD"}},"credit_history": {"items": [{"date": "2020-12-02 16:38:11","type": "ALLOCATION","amount": {"value": 0,"currency": "USD"},"balance": {"outstanding_balance": {"value": 0,"currency": "USD"},"available_credit": {"value": 500,"currency": "USD"},"credit_limit": {"value": 500,"currency": "USD"}}},{"date": "2020-12-02 17:05:12","type": "PURCHASE","amount": {"value": -192,"currency": "USD"},"balance": {"outstanding_balance": {"value": -192,"currency": "USD"},"available_credit": {"value": 308,"currency": "USD"},"credit_limit": {"value": 500,"currency": "USD"}}},{"date": "2020-12-02 17:27:57","type": "PURCHASE","amount": {"value": -64,"currency": "USD"},"balance": {"outstanding_balance": {"value": -256,"currency": "USD"},"available_credit": {"value": 244,"currency": "USD"},"credit_limit": {"value": 500,"currency": "USD"}}},{"date": "2020-12-02 17:35:47","type": "REIMBURSEMENT","amount": {"value": 192,"currency": "USD"},"balance": {"outstanding_balance": {"value": -64,"currency": "USD"},"available_credit": {"value": 436,"currency": "USD"},"credit_limit": {"value": 500,"currency": "USD"}}}]},"payment_methods": []}}}