1. Audits
  2. Retrieve Audit

Audits

Retrieve Audit

GET
`/v1/audits/:audit`

Get a single audit using its id.

js
        const response = await fetch("https://api.packagex.io/v1/audits/audit_1tH2ofoBcDbPnyZCYmrSX3", {
  method: "GET",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
}).then((res) => res.json());

const audit = response.data;

      

Grouping Tasks

By default, the audit's tasks array contains a flat list of audit_task objects. If you'd like the tasks grouped by item or by layout, pass a group_by query parameter. When group_by is supplied, tasks will be returned as an empty array and the tasks will be returned under either by_item (a map of item_id to tasks) or by_layout (a map of layout_id to tasks).

  • group_by - Can be by_item or by_layout.
js
        const response = await fetch("https://api.packagex.io/v1/audits/audit_1tH2ofoBcDbPnyZCYmrSX3?group_by=by_layout", {
  method: "GET",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
}).then((res) => res.json());

const audit = response.data;
const tasks_by_layout = audit.by_layout;

      

List Audits

Example

GET
`/v1/audits`

When you want to retrieve multiple audits, your data property on the result will always be an array even if you don't have any audits.

js
        const response = await fetch("https://api.packagex.io/v1/audits", {
  method: "GET",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
}).then((res) => res.json());

const audits = response.data; //the array of audits
const pagination = response.pagination; //the pagination object

      

Pagination

If the has_more property on the pagination object is set to true, there are more audits in the database that have not been returned. The pagination object also has a page property indicating your current offset and a limit property. The total_count property returns the total number of audits in the database.

By default the page is set to 1 and the limit is 25.

js
        const response = await fetch("https://api.packagex.io/v1/audits?page=2&limit=25", {
  method: "GET",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
}).then((res) => res.json());

const audits = response.data;
const pagination = response.pagination;

      

Filter

You can filter audits by location_id, item_id, layout_id, reason_code_id, assignee, status, priority, overdue, complete_at, finished_at, created_at, updated_at, created_by, and updated_by.

  • location_id - Filter audits at a specific location. For example: location_id=loc_czhgjrk5JaVvyATPDbyURp
js
        const response = await fetch("https://api.packagex.io/v1/audits?location_id=loc_8axWLqDo9kprqgNmFpCqxo", {
  method: "GET",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
}).then((res) => res.json());

const audits = response.data;
const pagination = response.pagination;

      
  • item_id - Filter audits that contain a task for a specific item. For example: item_id=item_5TngYZKdRFTSkcVCvNa885

  • layout_id - Filter audits that contain a task for a specific layout. For example: layout_id=lay_vgM65sMYtakxwfXkTCC8FB

  • reason_code_id - Filter audits that contain a task with a specific reason code. For example: reason_code_id=rsnc_aBcDeFgHiJkLmNoPqRsT

  • assignee - Filter audits assigned to a specific contact. For example: assignee=ctct_czhgjrk5JaVvyATPDbyURp

  • status - Filter audits by status. Supports the filter operators (eq, !eq, in, !in). Valid statuses are created, processing, in_review, recount, approved, and canceled. For example: status=in:processing,in_review

js
        const response = await fetch("https://api.packagex.io/v1/audits?status=in:processing,in_review", {
  method: "GET",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
}).then((res) => res.json());

const audits = response.data;
const pagination = response.pagination;

      
  • priority - Filter audits by priority. Valid priorities are low, medium, and high. For example: priority=high

  • overdue - Filter audits by their overdue flag. Accepts true or false. For example: overdue=true

  • complete_at - Filter audits by their scheduled completion date. Supports date filter operators (eq, !eq, gt, gte, lt, lte, bwe, bwi, in, !in). For example: complete_at=gte:1739898954

  • finished_at - Filter audits by the date they were approved. Supports date filter operators (eq, !eq, gt, gte, lt, lte, bwe, bwi, in, !in). For example: finished_at=gte:1739898954

  • created_at - Filter audits by creation date. Supports date filter operators (eq, !eq, gt, gte, lt, lte, bwe, bwi, in, !in). For example: created_at=gte:1739898954

  • updated_at - Filter audits by last updated date. Supports date filter operators (eq, !eq, gt, gte, lt, lte, bwe, bwi, in, !in). For example: updated_at=gte:1739898954

  • created_by - Filter audits by the user or API key that created them. Accepts a user_ or key_ prefixed ID. For example: created_by=user_czhgjrk5JaVvyATPDbyURp

  • updated_by - Filter audits by the user or API key that last updated them. Accepts a user_ or key_ prefixed ID. For example: updated_by=user_czhgjrk5JaVvyATPDbyURp

Grouping

You can also group the tasks within each returned audit using the same group_by parameter described above. The behavior matches the retrieve endpoint: tasks are returned under by_item or by_layout instead of the flat tasks array.

  • group_by - Can be by_item or by_layout.
js
        const response = await fetch("https://api.packagex.io/v1/audits?group_by=by_item", {
  method: "GET",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
}).then((res) => res.json());

const audits = response.data;

      

Sorting

Sorting describes in what order you want your responses to come in. You can select an available property by which to sort, as well as the direction.

  • order_by - The property by which to sort. Available properties are: created_at, updated_at, complete_at, finished_at, priority.
  • direction - The direction to sort. Available directions are: asc and desc.

By default, audits will be sorted by created_at in descending order, meaning the most recently created audits are returned first.

js
        const response = await fetch("https://api.packagex.io/v1/audits?order_by=complete_at&direction=asc", {
  method: "GET",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
}).then((res) => res.json());

const audits = response.data;
const pagination = response.pagination;

      

You can do a fuzzy, typo-tolerant search of every audit in the database by providing the search query parameter.

Searchable Properties

  • number

To search, simply provide a string to search by using the search query param. If you want to highlight matching search results for a frontend, we provide a special property for search-returned audit objects called _search which will have the matched text surrounded with <mark> handles.

Ordering Search Results

By default, search results are ordered by relevance. However, if you include an order_by parameter along with your search query, the results will be ordered by the specified property instead of by relevance.

js
        const response = await fetch("https://api.packagex.io/v1/audits?search=AUD-42", {
  method: "GET",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
}).then((res) => res.json());

const audit = response.data[0];