Search in space api: sort fails with "invalid sort property" with properties

Using the search in space http api, when I try to search by (many) properties it returns error 400 bad input: invalid sort property.

Example, using the Task type, trying to sort by either “due_date” or “priority” gets the 400 error.

POST http://127.0.0.1:31012/v1/spaces/$SPACEID/search
{
    "types": [
        "task"
    ],
    "sort": {
        "direction": "asc",
        "property_key": "due_date"
    }
}
{
    "object": "error",
    "status": 400,
    "code": "bad_request",
    "message": "bad input: invalid sort property: \"due_date\""
}

Sorting by “created_date” or “last_modified_date” works.

All Tasks in the space have both due_date and priority defined. I’ve checked that the property_key is valid by querying the types, and those property keys are unique in the space.

Note the json sample above has the type key “task”. It also fails using the type id “bafyrei…”.

Reported on github issue 2887 on Jan 9 but so far no response. That report has detailed json POST data and how to reproduce it.

THE EXPECTED BEHAVIOR

Sort on all properties should work, not just a few.

ADDITIONAL CONTEXT

As reported in the github issue, filtering on due_date does work, showing that it’s recognized as a valid property.

{
    "types": [
        "task"
    ],
    "filters": {
        "conditions": [
            {
                "condition": "gte",
                "property_key": "due_date",
                "date": "2026-01-05"
            }
        ],
        "operator": "and"
    }
}

Work-arounds I tried:

  • using object id of the property instead of property_key

  • created a new Type with those properties defined (so get_type query returns the type definition and shows those properties listed) and still get the same result - so it happens even if the property is defind for the type.

  • It happens with the “built-in” properties due_date and priority, and with custom properties

Github issue: API: search in space doesn't accept sort property "due_date" · Issue #2887 · anyproto/anytype-heart · GitHub

TECHNICAL INFORMATION

anytype-cli v0.1.3
macos (aarch64) and linux (aarch64)

This report has been added to our issue tracker and received by the Development Team.