Sorting

You can sort API results by one or more fields using the sort parameter. Separate multiple fields with commas.

If no sorting option is specified, results are sorted by their ID (for example, country ID, order ID, or CDR ID) in ascending order.

Note

Sorting applies to any endpoint that returns a resource collection as primary data, regardless of the request type.



Sorting DIDs by expiration date

You can retrieve a list of DIDs sorted by their expires_at attribute in ascending order (earliest expiration date first). Use this to view DIDs based on their expiration sequence and prioritize those that are expiring soon.

http

GET /v3/dids?sort=expires_at HTTP/1.1
Host: api.didww.com
Accept: application/vnd.api+json

curl

curl -i -X GET 'https://api.didww.com/v3/dids?sort=expires_at' -H "Accept: application/vnd.api+json"


Sorting by multiple fields

You can sort results by multiple fields, separated by commas. Fields are applied in the order they are listed.

In this example, results are sorted first by did_group.area_name and then, for DIDs with the same area name, by number in ascending order.

This helps you organize data hierarchically, starting with broader attributes and refining by more specific ones.

http

GET /v3/dids?sort=did_group.area_name%2Cnumber HTTP/1.1
Host: api.didww.com
Accept: application/vnd.api+json

curl

curl -i -X GET 'https://api.didww.com/v3/dids?sort=did_group.area_name%2Cnumber' -H "Accept: application/vnd.api+json"

In this example, DIDs are sorted by did_group.area_name first, and then by number.



Reverse sorting

Prefixing a field with a minus sign (-) sorts it in descending order. In this example, DIDs are sorted by did_group.area_name from Z to A, and then by number in ascending order within each area.

This is useful when you need to view the most recent or highest-value items first.

http

GET /v3/dids?sort=-did_group.area_name%2Cnumber HTTP/1.1
Host: api.didww.com
Accept: application/vnd.api+json

curl

curl -i -X GET 'https://api.didww.com/v3/dids?sort=-did_group.area_name%2Cnumber' -H "Accept: application/vnd.api+json"