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. Magento returns a union of these objects. Specify the __typename
attribute to distinguish the object types in the response.
Syntax
{company: {Company}}
Example usage
Return information about a newly-created company
The following call returns basic information about the customer’s company.
Request:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
query{
company{
company_admin {
firstname
lastname
email
}
email
id
legal_address {
street
city
region {
region_id
region_code
}
postcode
country_code
telephone
}
legal_name
name
}
}
Response:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{
"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:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
query{
company{
id
name
structure{
items {
entity {
__typename
... on Customer {
firstname
lastname
email
}
... on CompanyTeam {
name
description
id
}
}
}
}
}
}
Response:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{
"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:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
query{
company{
name
id
credit {
available_credit {
value
currency
}
credit_limit {
value
currency
}
outstanding_balance {
value
currency
}
}
credit_history{
items {
date
type
amount {
value
currency
}
balance {
outstanding_balance {
value
currency
}
available_credit {
value
currency
}
credit_limit {
value
currency
}
}
}
}
payment_methods
}
}
Response:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
{
"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": []
}
}
}
Output attributes
The company
object returns the Company
object.
The Company
object can contain the following attributes:
Attribute | Data type | Description |
---|---|---|
acl_resources |
[CompanyAclResource] | Returns the list of all resources defined within the company |
company_admin |
Customer | An object containing information about the company administrator |
credit |
CompanyCredit! | The company credit balance |
credit_history(filter: CompanyCreditHistoryFilterInput, pageSize: Int = 20, currentPage: Int = 1) |
CompanyCreditHistory! | A history of company credit operations |
email |
String | The email address of the company contact |
id |
ID! | The unique ID of a Company object |
legal_address |
CompanyLegalAddress | The address where the company is registered to conduct business |
legal_name |
String | The full legal name of the company |
name |
String | The name of the company |
payment_methods |
[String] | The list of payment methods available to a company |
reseller_id |
String | The resale number that is assigned to the company for tax reporting purposes |
role(id: ID!) |
CompanyRole | Returns a company role filtered by the unique ID for a CompanyRole object |
roles(pageSize: Int = 20, currentPage: Int = 1 ) |
CompanyRoles! | Returns the list of company roles |
sales_representative |
CompanySalesRepresentative | The company sales representative |
structure(rootId: ID = 0 depth: Int = 10 ) |
CompanyStructure | Returns the company structure of teams and customers in depth-first order |
team(id: ID!) |
CompanyTeam | Returns company team data filtered by the unique ID for a CompanyTeam object |
user(id: ID!) |
Customer | Returns a company user filtered by the unique ID for a Customer object |
users(filter: CompanyUsersFilterInput, pageSize: Int = 20, currentPage: Int = 1) |
CompanyUsers | Returns a list of company users based on activity status |
vat_tax_id |
String | The value-added tax number that is assigned to the company by some jurisdictions for tax reporting purposes |
CompanyAclResource attributes
The CompanyAclResource
object can contain the following attributes.
Attribute | Data Type | Description |
---|---|---|
children |
[CompanyAclResource!] | An array of sub-resources |
id |
ID! | The unique ID for a CompanyAclResource object |
sort_order |
Int | The sort order of an ACL resource |
text |
String | The label assigned to the ACL resource |
CompanyAdmin attributes
The CompanyAdmin
object can contain the following attributes.
Attribute | Data Type | Description |
---|---|---|
email |
String! | The email address of the company administrator |
firstname |
String! | The company administrator’s first name |
gender |
Int | The company administrator’s gender (Male - 1, Female - 2, Not Specified - 3) |
id |
ID! | The unique ID for a CompanyAdmin object |
job_title |
String | The job title of the company administrator |
lastname |
String! | The company administrator’s last name |
CompanyCredit
The CompanyCredit
object can contain the following attributes.
Attribute | Data Type | Description |
---|---|---|
available_credit |
Money! | The amount of company credit available |
credit_limit |
Money! | The company’s credit limit |
outstanding_balance |
Money! | The outstanding company credit amount |
CompanyCreditHistory attributes
The CompanyCreditHistory
object can contain the following attributes.
Attribute | Data Type | Description |
---|---|---|
items |
[CompanyCreditOperation]! | An array of company credit operations |
page_info |
SearchResultPageInfo! | Metadata for pagination rendering |
total_count |
Int | The number of the company credit operations matching the specified filter |
CompanyCreditHistoryFilterInput attributes
The CompanyCreditHistoryFilterInput
object can contain the following attributes.
Attribute | Data Type | Description |
---|---|---|
custom_reference_number |
String | Filters by the purchase order number associated with the company credit operation |
operation_type |
CompanyCreditOperationType | An enum that defines the type of the company credit operation. Possible values are ADMIN and CUSTOMER |
updated_by |
String | Filters by the name of the person submitting the company credit operation |
CompanyCreditOperation attributes
The CompanyCreditOperation
object can contain the following attributes.
Attribute | Data Type | Description |
---|---|---|
amount |
Money | The amount of the company credit operation |
balance |
CompanyCredit! | The credit balance after the company credit operation |
custom_reference_number |
String | The purchase order number associated with the company credit operation |
date |
String! | The date the operation was performed |
type |
CompanyCreditOperationType! | The type of the company credit operation. Possible values are ALLOCATION, PURCHASE, REFUND, REIMBURSEMENT, REVERT, UPDATE |
updated_by |
CompanyCreditOperationUser! | The company user submitting the company credit operation |
CompanyCreditOperationUser attributes
The CompanyCreditOperationUser
object can contain the following attributes.
Attribute | Data Type | Description |
---|---|---|
name |
String! | The name of the company user submitting the company credit operation |
type |
CompanyCreditOperationUserType! | The type of the company user submitting the company credit operation. Possible values are ADMIN and CUSTOMER |
CompanyLegalAddress attributes
The CompanyLegalAddress
object can contain the following attributes.
Attribute | Data Type | Description |
---|---|---|
city |
String! | The city where the company is registered to conduct business |
country_code |
CountryCodeEnum! | Company’s country ID. See the countries query |
postcode |
String! | The company’s postal code |
region |
CustomerAddressRegionInput! | An object containing the region name and/or region ID where the company is registered to conduct business |
street |
[String!]! | An array of strings that define the street address where the company is registered to conduct business |
telephone |
String! | The primary phone number of the company. |
CompanyRole attributes
The CompanyRole
object can contain the following attributes.
Attribute | Data Type | Description |
---|---|---|
id |
ID! | The unique ID for a CompanyRole object |
name |
String | The name assigned to the role |
permissions |
[CompanyAclResource] | A list of permission resources defined for a role |
users_count |
Int | The total number of users assigned the specified role |
CompanyRoles attributes
The CompanyRoles
object can contain the following attributes.
Attribute | Data Type | Description |
---|---|---|
items |
[CompanyRole]! | A list of company roles that match the specified filter criteria |
page_info |
SearchResultPageInfo | Pagination metadata |
total_count |
Int! | The total number of roles matching the specified filter |
CompanySalesRepresentative attributes
The CompanySalesRepresentative
object can contain the following attributes.
Attribute | Data Type | Description |
---|---|---|
email |
String! | The email address of the company sales representative |
firstname |
String! | The company sales representative’s first name |
lastname |
String! | The company sales representative’s last name |
CompanyStructure attributes
The CompanyStructure
object can contain the following attribute.
Attribute | Data Type | Description |
---|---|---|
items |
[CompanyStructureItem] | An array of elements in a company structure |
CompanyStructureItem attributes
The CompanyStructureItem
object can contain the following attributes.
Attribute | Data Type | Description |
---|---|---|
entity |
CompanyStructureEntity | A union of CompanyTeam and Customer objects |
id |
ID! | The unique ID for a CompanyStructureItem object |
parent_id |
ID | The ID of the parent item in the company hierarchy |
CompanyTeam attributes
The CompanyTeam
object contains details about a company team. It contains the following attributes.
Attribute | Data Type | Description |
---|---|---|
description |
String | An optional description of the team |
id |
ID! | The unique ID for a CompanyTeam object |
name |
String | The display name of the team |
CompanyUsers attributes
The CompanyUsers
object can contain the following attributes.
Attribute | Data Type | Description |
---|---|---|
items |
[Customer]! | An array of CompanyUser objects that match the specified filter criteria |
page_info |
SearchResultPageInfo | Pagination metadata |
total_count |
Int! | The number of objects returned |