Skip to content

Commit ca2a387

Browse files
committed
apiGeneral: calls: clarify internal IDs
Also add a header above the section detailing usage of internal IDs for permalinking. Change-type: patch Signed-off-by: Joseph Kogut <joseph@balena.io>
1 parent 26ecd3e commit ca2a387

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

shared/apiGeneral/calls.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ curl -X GET "{{ $links.apiBase }}/v5/device(<ID>)" \
4646
-H "Authorization: Bearer <AUTH_TOKEN>"
4747
```
4848

49+
## Resource IDs
50+
4951
Many times, however, you won't know the internal ID used by the API, and you'll want to use some other piece of information to find the appropriate resource. In these cases, you can use the `$filter` method to select resources based on any field. For example, if you are looking for a specific device, it's more likely that you'll have the device UUID than the device ID:
5052

5153
```shell
@@ -57,6 +59,10 @@ curl -X GET \
5759

5860
Notice the construction here: `$filter=` is used to define the field, and then the value is specified after the `eq` keyword. This is the most straightforward example—there are many other ways to build filters, which you can find in the OData documentation.
5961

62+
The resource returned from this call contains the internal ID you can use to make subsequent calls, under the "id" key.
63+
64+
`{"d":[{"id":1234567, ...`
65+
6066
A final tip for constructing API calls: for some of the fields in the API response, a link to another resource is provided rather than the complete information about that resource. For example, if you make a call requesting information about a specific device, the `belongs_to__application` field will return a link to an application, but not all the information about that application. To get all the fields for the application resource, you can use the `$expand` method:
6167

6268
```shell

0 commit comments

Comments
 (0)