externalIds
The externalIds query allows you to retrieve objects where you have attached your own (external) Ids.
3 minute read
Key Information
Use-Case
The externalIds
query allows you to search for objects in Marketplacer that may have had ExternalId(s) attached to them using the externalIdUpsert
mutation. ExternalIds are typically used to attach 3rd party system references to Marketplacer objects, e.g. Orders, Invoices and Adverts (aka Products), although many other object types support external Ids.
Further Points of Note
- We currently have 2 “external id” constructs:
ExternalId
(Singular) - This field is typically used only internally by Marketplacer and only stores 1 externalId valueExternalIds
(Plural) - This is a collection of key / value pairs, allowing API consumers to attach as many external Ids as they like to objects- The
externalIds
query relates only to theExternalIds
construct. I.e. you cannot use it to search for the singularexternalId
field.
- You can search by either
key
,value
or both of these - As external Ids can be attached to any object type, you need to specify the
ownerType
as part of your query arguments (e.g. Order, Invoice etc.), likewise to return object values for that concrete object type, you’ll need to specify an inline fragment in your query body, e.g.... on Invoice
- Sellers can use this query but may experience an
object permissions
error if their search could bring back objects scoped to other sellers
Availability
- Operator API: Yes
- Seller API: Yes (Scoped to Seller-owned objects only)
Example 1 - Providing a single value
query getInvoicesByExternalId{
externalIds(
ownerType: "Invoice"
key: "SYS1"
value: "3333"
) {
id
key
value
owner {
id
__typename
... on Invoice {
id
totalCents
lineItems{
id
variantName
}
seller{
businessName
}
}
}
}
}
Example 2 - Providing multiple values
query {
externalIds(
ownerType: "Variant"
key: "SYS1"
values: ["11112", "11113", "11114"]
) {
id
key
value
owner {
id
__typename
... on Variant {
id
label
countOnHand
}
}
}
}
Arguments
Name | Type | Description |
---|---|---|
ownerType | String | Specify the object type that the external Id has been attached to, e.g. Invoice, Advert etc. |
key | String | The key component of the external id. |
value | String | The value component of the external id. |
values | [String!] | As an alternative to supplying a single value , you can supply a collection of values. |
first | Int | Limit the results to the first N values |
Response
Returns [ExternalId!]
Error Responses
HTTP Error | Error Message | Meaning |
---|---|---|
401 | Unauthorized | You don’t have access to the endpoint, likely Basic Authentication credentials are missing |
401 | API Token has expired | You don’t have access to the endpoint, likely that you are either not supplying an API Key, or the key you are supplying is invalid |
200 | An object of type <type> was hidden due to permissions. | Most likely returned if a Seller is using the query, and the result set could include objects that don’t belong to them |