Approvals

Usage

Approve or reject a resource in a materialized approvals flow:

import asyncio
import factorialhr

async def main():
    auth = factorialhr.AccessTokenAuth("your_access_token")
    async with factorialhr.ApiClient(auth=auth) as api:
        flows = factorialhr.MaterializedApprovalsFlowsEndpoint(api)
        result = await flows.approve_resource(
            data={"resource_id": 123, "resource_type": "Timeoff::Leave"},
        )
        print(result.status)
        rejected = await flows.reject_resource(
            data={
                "resource_id": 456,
                "resource_type": "Timeoff::Leave",
                "reason": "Does not comply with policy",
            },
        )
        print(rejected.status)

asyncio.run(main())

Models and endpoints

class factorialhr.MaterializedApprovalsFlow(*, id: int, author_id: int | None = None, author_employee_id: int | None = None, owner_id: int | None = None, owner_employee_id: int | None = None, resource_type: str | None = None, resource_id: int | None = None, resource_url: str | None = None, status: str | None = None, expires_at: datetime | None = None, final_decision_at: datetime | None = None, approval_flow_id: int | None = None, approvers: Sequence[Any] = <factory>, email_detail_blocks: Sequence[Any] = <factory>, override_approver_id: int | None = None, override_approver_employee_id: int | None = None, rules_decision: str | None = None, auto_approval_description: str | None = None, action_type: str | None = None, reason: str | None = None)[source]

Model for approvals_materialized_approvals_flow.

action_type: str | None

Action type

approval_flow_id: int | None

Approval flow identifier

approvers: Sequence[Any]

List of approvers

author_employee_id: int | None

Author employee identifier

author_id: int | None

Author identifier

auto_approval_description: str | None

Auto approval description

email_detail_blocks: Sequence[Any]

Email detail blocks

expires_at: datetime | None

Expiration timestamp

final_decision_at: datetime | None

Final decision timestamp

id: int

Materialized approvals flow identifier

override_approver_employee_id: int | None

Override approver employee identifier

override_approver_id: int | None

Override approver identifier

owner_employee_id: int | None

Owner employee identifier

owner_id: int | None

Owner identifier

reason: str | None

Reason for rejection

resource_id: int | None

Id of the resource

resource_type: str | None

Type of the resource (e.g. Timeoff::Leave)

resource_url: str | None

URL of the resource

rules_decision: str | None

Rules decision

status: str | None

Status of the approval flow

class factorialhr.MaterializedApprovalsFlowsEndpoint(api: ApiClient)[source]

Endpoint for approvals/materialized_approvals_flows operations.

async approve_resource(data: Mapping[str, Any], **kwargs) MaterializedApprovalsFlow[source]

Approve resources in a materialized approvals flow.

Official documentation: approvals/materialized_approvals_flows

Parameters:
  • data (Mapping[str, Any]) – Payload with resource_id and resource_type (key-value mapping).

  • kwargs (optional) – Optional keyword arguments (e.g. params for query string) forwarded to the HTTP request.

Raises:

httpx.HTTPStatusError – When the API returns an error status code.

Returns:

The updated approval flow.

Return type:

MaterializedApprovalsFlow

async reject_resource(data: Mapping[str, Any], **kwargs) MaterializedApprovalsFlow[source]

Reject resources in a materialized approvals flow.

Official documentation: approvals/materialized_approvals_flows

Parameters:
  • data (Mapping[str, Any]) – Payload with resource_id, resource_type, and optional reason (key-value mapping).

  • kwargs (optional) – Optional keyword arguments (e.g. params for query string) forwarded to the HTTP request.

Raises:

httpx.HTTPStatusError – When the API returns an error status code.

Returns:

The updated approval flow.

Return type:

MaterializedApprovalsFlow