Skip to content

API Reference parrot_tools.interfaces.workday.rest

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_tools.interfaces.workday.rest

View source

Workday REST API client (/ccx/api).

Minimal async client for Workday's REST surface, sharing :class:WorkdayConfig (credentials, tenant, prod/sandbox env selector) with the SOAP WorkdayService. Unlike the WSDL services — which have no operation to read raw time clock events — the REST API exposes them, echoing back the client-assigned Time_Clock_Event_ID as reference_ID and the effective timeEntryCode applied to In events. That makes post-punch verification possible.

Built on aiohttp per project convention; this is a from-scratch reimplementation of the equivalent flowtask client on a different HTTP transport, preserving its public surface verbatim.

Verified endpoints (Workday implementation tenant, 2026-07-03):

  • GET /ccx/api/v1/{tenant}/workers?search={text} — worker lookup; each row carries id (the Workday WID) and descriptor.
  • GET /ccx/api/timeTracking/v5/{tenant}/timeClockEvents?worker={WID} — raw clock events. The worker parameter requires a WID; Employee_ID values are rejected with 400 "not found".

Example::

from parrot_tools.interfaces.workday.config import WorkdayConfig
from parrot_tools.interfaces.workday.rest import WorkdayRestClient

async with WorkdayRestClient(config=WorkdayConfig(env="sandbox")) as client:
    workers = await client.find_worker("123456")
    events = await client.get_time_clock_events(workers[0]["id"])

The aiohttp session is long-lived — the flowtask implementation this replaces opened a throwaway HTTP client per call and so needed no teardown, whereas here the session MUST be released: use the context manager above, or call close() in a finally. A client kept as a module-level singleton needs its close() registered on application shutdown (app.on_cleanup) — otherwise aiohttp logs "Unclosed client session" at exit.

Alias WorkdayConfig

Re-exported from parrot_tools.interfaces.workday.config.WorkdayConfig.

Class WorkdayRestClient

Async client for Workday's /ccx/api REST endpoints (aiohttp-based).

Uses the same OAuth refresh-token grant as SOAPClient (no Redis dependency — the bearer token is cached in-memory until shortly before expiry). Host and credentials come from :class:WorkdayConfig, so the WORKDAY_ENV prod/sandbox selector applies here too.

Parameter Type Default Description
config WorkdayConfig | None None Explicit credentials / tenant. None → WorkdayConfig() (conf fallbacks + WORKDAY_ENV).
timeout int 30 HTTP timeout in seconds (default 30).
time_tracking_version str 'v5' REST version segment for the timeTracking service (default "v5" — the version available on this tenant; v6 returned 400 when probed).

Attributes:

Attribute Type Description
base_url str REST base: {workday_url}/ccx/api (env-aware host).

Method WorkdayRestClient.close

Close the underlying aiohttp session, if one was opened.

close() -> None

Method WorkdayRestClient.set_token

Reuse an externally obtained bearer token (e.g. from the SOAP flow).

set_token(token: str, expires_in: int = 300) -> None

Parameter Type Default Description
token str A valid Workday OAuth access token.
expires_in int 300 Seconds the token remains valid (default 300).

Method WorkdayRestClient.get_token

Return a cached bearer token, refreshing via OAuth when expired.

Performs the same refresh_token grant as SOAPClient (Basic auth with client_id/client_secret against token_url).

get_token() -> str

Returns: str — A valid access token.

Method WorkdayRestClient.get

Perform an authenticated GET against {base_url}{path}.

A 401 despite a cached token triggers exactly ONE re-authentication (the cached token is discarded and a fresh one obtained); a second 401 propagates as an aiohttp.ClientResponseError.

get(path: str, params: dict[str, Any] | None = None) -> dict

Parameter Type Default Description
path str Path below /ccx/api (must start with /).
params dict[str, Any] | None None Optional query parameters.

Returns: dict — The parsed JSON body.

Raises:

  • aiohttp.ClientResponseError — on non-2xx responses.

Method WorkdayRestClient.find_worker

Search workers; each result carries id (WID) and descriptor.

find_worker(search: str, *, limit: int = 20) -> list[dict]

Parameter Type Default Description
search str Free-text search (name; associate/employee id support is tenant-dependent — verify before relying on it).
limit int 20 Max results (default 20).

Returns: list[dict] — List of worker dicts (empty when no match).

Method WorkdayRestClient.get_time_clock_events

Return the raw time clock events of a worker.

Each event carries reference_ID (the client-assigned Time_Clock_Event_ID when the event was created via Put_Time_Clock_Events), dateTime (UTC ISO), eventType, comment, timeZone, and — on In events of time-tracking eligible workers — the effective timeEntryCode.

get_time_clock_events(worker_wid: str, *, limit: int = 100, **criteria: Any) -> list[dict]

Parameter Type Default Description
worker_wid str The worker's Workday WID (NOT an Employee_ID — the REST API rejects those).
limit int 100 Max events returned (default 100).
**criteria Any {} Additional query parameters forwarded verbatim.

Returns: list[dict] — List of event dicts (empty when the worker has none).

Raises:

  • WorkdayRestError — Workday rejected the request with 400 — the actionable, most common cause being an Employee_ID passed where a WID is required.

Method WorkdayRestClient.find_time_clock_event

Locate one clock event by its client-assigned reference_ID.

Convenience for punch verification: after Put_Time_Clock_Events succeeds, the event is visible here within ~1 s (verified live).

find_time_clock_event(worker_wid: str, reference_id: str) -> dict | None

Parameter Type Default Description
worker_wid str The worker's Workday WID.
reference_id str The Time_Clock_Event_ID sent on the Put.

Returns: dict | None — The matching event dict, or None when not (yet) present.

Class WorkdayRestError

Raised for actionable Workday REST API failures.

Distinguishes application-level, actionable failures (e.g. a WID/Employee_ID mismatch) from an opaque aiohttp.ClientResponseError.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally