---
title: "searchRepoCustomRecordsAtCommit"
---

> Documentation Index
> Fetch the complete documentation index at: https://buildrforge.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# searchRepoCustomRecordsAtCommit

Path: Forge API › customRecords

`POST /repos/{repo_id}/commits/{commit_id}/custom-models/{model_api_name}/records/search`

Search a custom model's records at the commit. Body: { where?, sort?, limit?, cursor?, explain? }. Answers { data, next_cursor, total }: total counts every record where holds at the revision read (on a branch, as of this request), on every page, so for "how many ...?" send limit: 1 and read total.
where is a tree whose nodes each have one kind key: {and:[...]}, {or:[...]}, {not:{...}}; {field, op, value} compares a custom field by API name; {field, op:"matches", where} holds when the record a reference field points at matches where; {tag: tagId} holds for records carrying the tag or a tag beneath it (ids from listRepoTagsAtBranch); {ids: [recordId, ...]} holds for the records with those ids; {referenced_by:{model, field, where?}} holds when at least one record of model points here through its reference field (and matches where); add count: one of {eq|ne|gt|gte|lt|lte: n} to compare how many do ({gt:1} more than one, {eq:0} none), or use every:{...} alone for "every such record matches" (true when none do).
Operators by field type, as each field's filter.operators in listRepoCustomModelsAtBranch also lists them: text and rich_text: eq, ne, in, not_in, contains, not_contains, starts_with, ends_with, is_empty, is_not_empty; integer, decimal, currency, percent, date, datetime and duration: eq, ne, gt, gte, lt, lte, between, in, not_in, is_empty, is_not_empty; boolean: eq, ne, is_empty, is_not_empty; picklist and user: eq, ne, in, not_in, is_empty, is_not_empty; multi_picklist: eq, ne, has_any, has_all, has_none, is_empty, is_not_empty; geo, attachment and multi_attachment: is_empty, is_not_empty; reference: eq, ne, in, not_in, is_empty, is_not_empty, matches. between takes [low, high]; a multi_picklist's eq is the exact set.
Values are in their write form: currency integer cents (5000000 is $50,000), percent basis points (1500 is 15%), date YYYY-MM-DD, datetime epoch milliseconds, duration seconds, references and users by id, picklists by option key. A formula field filters as the type it infers.
Every condition is true or false: ne, not_in, not_contains, has_none, and not match records whose value is empty; every other comparison never does. Match empty values with is_empty or is_not_empty; null is refused. in: [] matches nothing. Text compares ignoring the case of ASCII letters only.
sort: up to 3 keys {field, direction?: "asc"|"desc", nulls?: "first"|"last"}; empty values sort last by default either way, text ignoring case, a picklist in option order, and ties by record id. Page with limit (at most 1000, the default) and by passing next_cursor back as cursor with the same where and sort. explain: true adds explain, the filter as read with each field's type and operators.
Caps: 160 nodes, nesting 7 deep, 3 nested matches/referenced_by and 16 in all, 1000 values in a list, 256 bytes in a text value.
Errors: InvalidRecordFilter (400) lists up to 20 problems as { path, reason } and counts the rest in more_problems; RecordSearchLimitExceeded (400) names the cap, its maximum, and the actual count; InvalidCursor (400) says whether the cursor is from another search or the schema changed. A body past 65536 bytes is refused with RequestBodyTooLarge.

## Path parameters

- `repo_id` (`searchRepoCustomRecordsAtCommit.path.repo_id`; string, required)
  - pattern: `^repo_[0-7][0-9a-hjkmnp-tv-z]{25}$`
- `commit_id` (`searchRepoCustomRecordsAtCommit.path.commit_id`; string, required)
  - pattern: `^commit_[0-7][0-9a-hjkmnp-tv-z]{25}$`
- `model_api_name` (`searchRepoCustomRecordsAtCommit.path.model_api_name`; string, required)
  - minLength: `1`

## Request body

_Required._

- `where` (`searchRepoCustomRecordsAtCommit.where`; any of, optional)
  - any of the following:
    - `RecordFilter`
      - any of the following:
        - `AndFilter`
          - `and` (`AndFilter.and`; array of RecordFilter, required)
            - any of the following: `AndFilter`, `OrFilter`, `NotFilter`, `FieldCondition`, `TagCondition`, `IdsCondition`, `ReferencedByConditionEncoded`
        - `OrFilter`
          - `or` (`OrFilter.or`; array of RecordFilter, required)
            - any of the following: `AndFilter`, `OrFilter`, `NotFilter`, `FieldCondition`, `TagCondition`, `IdsCondition`, `ReferencedByConditionEncoded`
        - `NotFilter`
          - `not` (`NotFilter.not`; RecordFilter, required)
            - any of the following: `AndFilter`, `OrFilter`, `NotFilter`, `FieldCondition`, `TagCondition`, `IdsCondition`, `ReferencedByConditionEncoded`
        - `FieldCondition`
          - `field` (`FieldCondition.field`; string, required) — The custom field's API name.
            - minLength: `1`
          - `op` (`FieldCondition.op`; string, required)
            - one of `"eq"`, `"ne"`, `"gt"`, `"gte"`, `"lt"`, `"lte"`, `"between"`, `"in"`, `"not_in"`, `"contains"`, `"not_contains"`, `"starts_with"`, `"ends_with"`, `"has_any"`, `"has_all"`, `"has_none"`, `"is_empty"`, `"is_not_empty"`, `"matches"`
          - `value` (`FieldCondition.value`; unknown, optional) — The value in its write form (cents, basis points, YYYY-MM-DD, epoch ms, seconds, ids); a list for in, not_in, has_any, has_all, has_none, and a multi_picklist eq; a [low, high] pair for between. Left out for is_empty, is_not_empty, and matches.
          - `where` (`FieldCondition.where`; RecordFilter, optional)
            - any of the following: `AndFilter`, `OrFilter`, `NotFilter`, `FieldCondition`, `TagCondition`, `IdsCondition`, `ReferencedByConditionEncoded`
        - `TagCondition`
          - `tag` (`TagCondition.tag`; string, required)
            - pattern: `^[a-z](?:[a-z_]{0,61}[a-z])?_[0-7][0-9a-hjkmnp-tv-z]{25}$`
        - `IdsCondition`
          - `ids` (`IdsCondition.ids`; array of string, required)
            - pattern: `^[a-z](?:[a-z_]{0,61}[a-z])?_[0-7][0-9a-hjkmnp-tv-z]{25}$`
        - `ReferencedByConditionEncoded`
          - `referenced_by` (`ReferencedByConditionEncoded.referenced_by`; object, required)
            - `model` (`ReferencedByConditionEncoded.referenced_by.model`; string, required) — The referencing model's API name.
              - minLength: `1`
            - `field` (`ReferencedByConditionEncoded.referenced_by.field`; string, required) — Its reference field that points at this model.
              - minLength: `1`
            - `where` (`ReferencedByConditionEncoded.referenced_by.where`; RecordFilter, optional)
              - any of the following: `AndFilter`, `OrFilter`, `NotFilter`, `FieldCondition`, `TagCondition`, `IdsCondition`, `ReferencedByConditionEncoded`
            - `count` (`ReferencedByConditionEncoded.referenced_by.count`; object, optional) — Exactly one comparison of how many records point here: { gt: 1 } is more than one, { eq: 0 } is none.
              - `eq` (`ReferencedByConditionEncoded.referenced_by.count.eq`; integer, optional)
                - maximum: `9007199254740991` · minimum: `0`
              - `ne` (`ReferencedByConditionEncoded.referenced_by.count.ne`; integer, optional)
                - maximum: `9007199254740991` · minimum: `0`
              - `gt` (`ReferencedByConditionEncoded.referenced_by.count.gt`; integer, optional)
                - maximum: `9007199254740991` · minimum: `0`
              - `gte` (`ReferencedByConditionEncoded.referenced_by.count.gte`; integer, optional)
                - maximum: `9007199254740991` · minimum: `0`
              - `lt` (`ReferencedByConditionEncoded.referenced_by.count.lt`; integer, optional)
                - maximum: `9007199254740991` · minimum: `0`
              - `lte` (`ReferencedByConditionEncoded.referenced_by.count.lte`; integer, optional)
                - maximum: `9007199254740991` · minimum: `0`
            - `every` (`ReferencedByConditionEncoded.referenced_by.every`; RecordFilter, optional)
              - any of the following: `AndFilter`, `OrFilter`, `NotFilter`, `FieldCondition`, `TagCondition`, `IdsCondition`, `ReferencedByConditionEncoded`
    - `null`
- `sort` (`searchRepoCustomRecordsAtCommit.sort`; array of object, optional)
  - `field` (`searchRepoCustomRecordsAtCommit.sort.field`; string, required) — The custom field's API name.
    - minLength: `1`
  - `direction` (`searchRepoCustomRecordsAtCommit.sort.direction`; string, optional)
    - one of `"asc"`, `"desc"`
  - `nulls` (`searchRepoCustomRecordsAtCommit.sort.nulls`; string, optional)
    - one of `"first"`, `"last"`
- `limit` (`searchRepoCustomRecordsAtCommit.limit`; integer, optional)
  - maximum: `1000` · minimum: `1`
- `cursor` (`searchRepoCustomRecordsAtCommit.cursor`; any of, optional)
  - any of the following: `PageCursor`, `null`
- `explain` (`searchRepoCustomRecordsAtCommit.explain`; boolean, optional)

## Example request

```json
{
  "where": {
    "and": [
      {
        "and": []
      }
    ]
  },
  "sort": [
    {
      "field": "string",
      "direction": "asc",
      "nulls": "first"
    }
  ],
  "limit": 1,
  "cursor": "string",
  "explain": true
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url '<base-url>/repos/<repo_id>/commits/<commit_id>/custom-models/<model_api_name>/records/search' \
  --header 'Content-Type: application/json' \
  --data '
{
  "where": {
    "and": [
      {
        "and": []
      }
    ]
  },
  "sort": [
    {
      "field": "string",
      "direction": "asc",
      "nulls": "first"
    }
  ],
  "limit": 1,
  "cursor": "string",
  "explain": true
}
'
```

### TypeScript

```typescript
const url = '<base-url>/repos/<repo_id>/commits/<commit_id>/custom-models/<model_api_name>/records/search';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    where: {and: [{and: []}]},
    sort: [{field: 'string', direction: 'asc', nulls: 'first'}],
    limit: 1,
    cursor: 'string',
    explain: true
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "<base-url>/repos/<repo_id>/commits/<commit_id>/custom-models/<model_api_name>/records/search"

payload = {
    "where": { "and": [{ "and": [] }] },
    "sort": [
        {
            "field": "string",
            "direction": "asc",
            "nulls": "first"
        }
    ],
    "limit": 1,
    "cursor": "string",
    "explain": True
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

CustomRecordSearchPage

#### Example

```json
{
  "data": [
    {
      "id": "string",
      "fields": {
        "property1": {
          "id": "string",
          "filename": "string",
          "content_type": "string",
          "size": 0,
          "created_by_id": "string",
          "created_at": "string",
          "uploaded_at": "string",
          "promoted_at": "string"
        },
        "property2": {
          "id": "string",
          "filename": "string",
          "content_type": "string",
          "size": 0,
          "created_by_id": "string",
          "created_at": "string",
          "uploaded_at": "string",
          "promoted_at": "string"
        }
      },
      "formulas": {
        "property1": "string",
        "property2": "string"
      }
    }
  ],
  "next_cursor": "string",
  "references": [
    {
      "record_id": "string",
      "live": {
        "model_api_name": "string",
        "label": "string"
      }
    }
  ],
  "users": [
    {
      "id": "string",
      "display_name": "string"
    }
  ],
  "total": -9007199254740991,
  "explain": {
    "where": {},
    "sort": [
      {
        "field": "string",
        "type": "string",
        "direction": "asc",
        "nulls": "first"
      }
    ]
  }
}
```

- `data` (`searchRepoCustomRecordsAtCommit.response.200.data`; array of object, required)
  - `id` (`searchRepoCustomRecordsAtCommit.response.200.data.id`; string, required)
    - pattern: `^[a-z](?:[a-z_]{0,61}[a-z])?_[0-7][0-9a-hjkmnp-tv-z]{25}$`
  - `fields` (`searchRepoCustomRecordsAtCommit.response.200.data.fields`; map of any of, required)
  - `formulas` (`searchRepoCustomRecordsAtCommit.response.200.data.formulas`; map of string, required)
- `next_cursor` (`searchRepoCustomRecordsAtCommit.response.200.next_cursor`; any of, required)
  - any of the following: `PageCursor`, `null`
- `references` (`searchRepoCustomRecordsAtCommit.response.200.references`; array of object, required) — The records in this repo that the page's reference fields hold, at the revision the page reads. live holds a record's model and label, the value of its primary field, or its model's name and the end of its id when that is empty; live is null for a deleted record. A record the caller can't read has no entry. A reference to another repo's record has none either: ask that repo's searchRepoCustomRecordLabelsAtBranch.
  - `record_id` (`searchRepoCustomRecordsAtCommit.response.200.references.record_id`; string, required)
    - pattern: `^[a-z](?:[a-z_]{0,61}[a-z])?_[0-7][0-9a-hjkmnp-tv-z]{25}$`
  - `live` (`searchRepoCustomRecordsAtCommit.response.200.references.live`; any of, required)
    - any of the following:
      - `LiveReferencedRecord`
        - `model_api_name` (`LiveReferencedRecord.model_api_name`; string, required)
          - minLength: `1`
        - `label` (`LiveReferencedRecord.label`; string, required)
          - minLength: `1`
      - `null`
- `users` (`searchRepoCustomRecordsAtCommit.response.200.users`; array of object, required) — The users that the page's user fields name, with their display names.
  - `id` (`searchRepoCustomRecordsAtCommit.response.200.users.id`; string, required)
    - pattern: `^(?:user|extension)_[0-7][0-9a-hjkmnp-tv-z]{25}$`
  - `display_name` (`searchRepoCustomRecordsAtCommit.response.200.users.display_name`; string, required)
    - minLength: `1`
- `total` (`searchRepoCustomRecordsAtCommit.response.200.total`; integer, required) — How many records the search holds at the revision read, on every page; on a branch, as of this request.
  - maximum: `9007199254740991` · minimum: `-9007199254740991`
- `explain` (`searchRepoCustomRecordsAtCommit.response.200.explain`; object, optional)
  - `where` (`searchRepoCustomRecordsAtCommit.response.200.explain.where`; any of, required)
    - any of the following: `Option 1`, `null`
  - `sort` (`searchRepoCustomRecordsAtCommit.response.200.explain.sort`; array of object, required)
    - `field` (`searchRepoCustomRecordsAtCommit.response.200.explain.sort.field`; string, required)
    - `type` (`searchRepoCustomRecordsAtCommit.response.200.explain.sort.type`; string, required)
    - `direction` (`searchRepoCustomRecordsAtCommit.response.200.explain.sort.direction`; string, required)
      - one of `"asc"`, `"desc"`
    - `nulls` (`searchRepoCustomRecordsAtCommit.response.200.explain.sort.nulls`; string, required)
      - one of `"first"`, `"last"`

### 400

InvalidCursor | InvalidRecordFilter | RecordSearchLimitExceeded | InvalidRequest | RequestBodyTooDeep

#### Example

```json
{
  "_tag": "InvalidCursor",
  "reason": "string"
}
```

Any of the following:

- `InvalidCursorEncoded`
  - `_tag` (`InvalidCursorEncoded._tag`; string, required)
    - one of `"InvalidCursor"`
  - `reason` (`InvalidCursorEncoded.reason`; string, required)
    - minLength: `1`
- `InvalidRecordFilterEncoded`
  - `_tag` (`InvalidRecordFilterEncoded._tag`; string, required)
    - one of `"InvalidRecordFilter"`
  - `problems` (`InvalidRecordFilterEncoded.problems`; array of object, required)
    - `path` (`InvalidRecordFilterEncoded.problems.path`; array\<any of\>, required)
      - any of the following: `string`, `integer`
    - `reason` (`InvalidRecordFilterEncoded.problems.reason`; string, required)
      - minLength: `1`
  - `more_problems` (`InvalidRecordFilterEncoded.more_problems`; integer, required)
    - maximum: `9007199254740991` · minimum: `-9007199254740991`
- `RecordSearchLimitExceededEncoded`
  - `_tag` (`RecordSearchLimitExceededEncoded._tag`; string, required)
    - one of `"RecordSearchLimitExceeded"`
  - `limit` (`RecordSearchLimitExceededEncoded.limit`; string, required)
    - one of `"nodes"`, `"depth"`, `"relation_hops"`, `"relations"`, `"list_values"`, `"text_value_bytes"`, `"sort_keys"`
  - `maximum` (`RecordSearchLimitExceededEncoded.maximum`; integer, required)
    - maximum: `9007199254740991` · minimum: `-9007199254740991`
  - `actual` (`RecordSearchLimitExceededEncoded.actual`; integer, required)
    - maximum: `9007199254740991` · minimum: `-9007199254740991`
- `InvalidRequestEncoded`
  - `_tag` (`InvalidRequestEncoded._tag`; string, required)
    - one of `"InvalidRequest"`
  - `part` (`InvalidRequestEncoded.part`; string, required)
    - one of `"path"`, `"query"`, `"headers"`, `"body"`
  - `issues` (`InvalidRequestEncoded.issues`; array of object, required)
    - `path` (`InvalidRequestEncoded.issues.path`; array\<any of\>, required)
      - any of the following: `string`, `integer`
    - `message` (`InvalidRequestEncoded.issues.message`; string, required)
- `RequestBodyTooDeepEncoded`
  - `_tag` (`RequestBodyTooDeepEncoded._tag`; string, required)
    - one of `"RequestBodyTooDeep"`
  - `max_depth` (`RequestBodyTooDeepEncoded.max_depth`; integer, required)
    - maximum: `9007199254740991` · minimum: `-9007199254740991`

### 401

InvalidCredentials

#### Example

```json
{
  "_tag": "InvalidCredentials"
}
```

- `_tag` (`searchRepoCustomRecordsAtCommit.response.401._tag`; string, required)
  - one of `"InvalidCredentials"`

### 403

Forbidden | ForbiddenOrigin | RequiresPersonalSession | RunBranchRequired

#### Example

```json
{
  "_tag": "Forbidden",
  "message": "string"
}
```

Any of the following:

- `ForbiddenEncoded`
  - `_tag` (`ForbiddenEncoded._tag`; string, required)
    - one of `"Forbidden"`
  - `message` (`ForbiddenEncoded.message`; string, required)
- `ForbiddenOriginEncoded`
  - `_tag` (`ForbiddenOriginEncoded._tag`; string, required)
    - one of `"ForbiddenOrigin"`
- `RequiresPersonalSessionEncoded`
  - `_tag` (`RequiresPersonalSessionEncoded._tag`; string, required)
    - one of `"RequiresPersonalSession"`
- `RunBranchRequiredEncoded`
  - `_tag` (`RunBranchRequiredEncoded._tag`; string, required)
    - one of `"RunBranchRequired"`
  - `branch` (`RunBranchRequiredEncoded.branch`; string, required)
    - minLength: `1`
  - `message` (`RunBranchRequiredEncoded.message`; string, required)

### 404

CommitNotFound | CustomModelNotFound | RepoNotFound

#### Example

```json
{
  "_tag": "CommitNotFound",
  "commit_id": "string"
}
```

Any of the following:

- `CommitNotFoundEncoded`
  - `_tag` (`CommitNotFoundEncoded._tag`; string, required)
    - one of `"CommitNotFound"`
  - `commit_id` (`CommitNotFoundEncoded.commit_id`; string, required)
    - pattern: `^commit_[0-7][0-9a-hjkmnp-tv-z]{25}$`
- `CustomModelNotFoundEncoded`
  - `_tag` (`CustomModelNotFoundEncoded._tag`; string, required)
    - one of `"CustomModelNotFound"`
  - `api_name` (`CustomModelNotFoundEncoded.api_name`; string, required)
    - minLength: `1`
- `RepoNotFoundEncoded`
  - `_tag` (`RepoNotFoundEncoded._tag`; string, required)
    - one of `"RepoNotFound"`

### 413

RequestBodyTooLarge

#### Example

```json
{
  "_tag": "RequestBodyTooLarge",
  "max_bytes": -9007199254740991
}
```

- `_tag` (`searchRepoCustomRecordsAtCommit.response.413._tag`; string, required)
  - one of `"RequestBodyTooLarge"`
- `max_bytes` (`searchRepoCustomRecordsAtCommit.response.413.max_bytes`; integer, required)
  - maximum: `9007199254740991` · minimum: `-9007199254740991`

### 429

RateLimited

#### Example

```json
{
  "_tag": "RateLimited"
}
```

- `_tag` (`searchRepoCustomRecordsAtCommit.response.429._tag`; string, required)
  - one of `"RateLimited"`

### 500

RepoFailure

#### Example

```json
{
  "_tag": "RepoFailure",
  "reason": "string"
}
```

- `_tag` (`searchRepoCustomRecordsAtCommit.response.500._tag`; string, required)
  - one of `"RepoFailure"`
- `reason` (`searchRepoCustomRecordsAtCommit.response.500.reason`; string, required)

### 503

SessionUnavailable | RateLimitUnavailable

#### Example

```json
{
  "_tag": "SessionUnavailable"
}
```

Any of the following:

- `SessionUnavailableEncoded`
  - `_tag` (`SessionUnavailableEncoded._tag`; string, required)
    - one of `"SessionUnavailable"`
- `RateLimitUnavailableEncoded`
  - `_tag` (`RateLimitUnavailableEncoded._tag`; string, required)
    - one of `"RateLimitUnavailable"`


Source: https://buildrforge.com/docs/api/search-repo-custom-records-at-commit/index.md
