Api Public

Usage

Create credentials for OAuth or manage webhook subscriptions:

import asyncio
import factorialhr

async def main():
    auth = factorialhr.AccessTokenAuth("your_access_token")
    async with factorialhr.ApiClient(auth=auth) as api:
        creds = factorialhr.CredentialsEndpoint(api)
        # List credentials (e.g. to inspect OAuth clients)
        response = await creds.get()
        for c in response.data():
            print(c.client_id, c.scope)

        subs = factorialhr.WebhookSubscriptionEndpoint(api)
        # List webhook subscriptions and filter by event
        all_subs = await subs.all()
        for sub in all_subs.data():
            print(sub.event, sub.callback_url)

asyncio.run(main())
class factorialhr.Credentials(*, company_id: int, id: str, email: str | None = None, login_email: str | None = None, full_name: str | None = None, first_name: str | None = None, last_name: str | None = None, employee_id: int | None = None, role: str | None = None, gdpr_tos: bool | None = None, legal_name: str | None = None, locale: str | None = None, logo: str | None = None, name: str | None = None, onboarded_on: str | None = None, subscription_plan: str | None = None, tin: str | None = None, to_be_deleted: str | None = None, tos: bool | None = None)[source]

Model for api_public_credential.

company_id: int

Company id for all kind of accesses.

email: str | None

Only for Access Oauth token.

employee_id: int | None

Id for the employee related. Only for Access Oauth token.

first_name: str | None

Only for Access Oauth token.

full_name: str | None

Full name of the user.

gdpr_tos: bool | None

Only for Company Oauth or API key.

id: str

Id of the credential prefixed by the type of credential.

last_name: str | None

Only for Access Oauth token.

legal_name: str | None

Only for Company Oauth or API key.

locale: str | None

Only for Company Oauth or API key.

login_email: str | None

Only for Access Oauth token.

Only for Company Oauth or API key.

name: str | None

Only for Company Oauth or API key.

onboarded_on: str | None

Only for Company Oauth or API key.

role: str | None

Employee role in the Company. Only for Access Oauth token.

subscription_plan: str | None

Only for Company Oauth or API key.

tin: str | None

Only for Company Oauth or API key.

to_be_deleted: str | None

Only for Company Oauth or API key.

tos: bool | None

Only for Company Oauth or API key.

class factorialhr.CredentialsEndpoint(api: ApiClient)[source]
async all(**kwargs) ListApiResponse[Credentials][source]

Get all credentials.

Official documentation: api_public/credentials

Returns:

List of credentials

Return type:

ListApiResponse[Credentials]

Parameters:

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:

Response containing the list of records.

Return type:

ListApiResponse[Credentials]

async get(**kwargs) MetaApiResponse[Credentials][source]

Get credentials with pagination metadata.

Official documentation: api_public/credentials

Parameters:

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:

Response containing records and pagination metadata.

Return type:

MetaApiResponse[Credentials]

class factorialhr.WebhookSubscription(*, id: int, target_url: str, type: str, company_id: int | None = None, name: str | None = None, challenge: str | None = None, enabled: bool, api_version: str)[source]

Model for api_public_webhook_subscription.

api_version: str

API version of the webhook subscription that determines the schema of the payload.

challenge: str | None

String to verify the subscription.

company_id: int | None

Company identifier of the webhook subscription.

enabled: bool

Boolean to enable/disable the subscription.

id: int

Identifier of the webhook subscription.

name: str | None

Name of the webhook subscription.

target_url: str

URL where the webhook payload will be sent.

type: str

Type of the webhook subscription.

class factorialhr.WebhookSubscriptionEndpoint(api: ApiClient)[source]
async all(**kwargs) ListApiResponse[WebhookSubscription][source]

Get all webhooks.

Official documentation: api_public/webhook_subscriptions

Parameters:

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:

Response containing the list of records.

Return type:

ListApiResponse[WebhookSubscription]

async create(data: Mapping[str, Any], **kwargs) WebhookSubscription[source]

Create a new webhook subscription.

Official documentation: api_public/webhook_subscriptions

Parameters:
  • data (Mapping[str, Any]) – Payload for the new record (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 created record.

Return type:

WebhookSubscription

async delete(webhook_subscription_id: int | str, **kwargs) WebhookSubscription[source]

Delete a webhook subscription.

Official documentation: api_public/webhook_subscriptions

Parameters:
  • webhook_subscription_id (int | str) – The unique identifier of the record to delete.

  • 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 deleted record.

Return type:

WebhookSubscription

async get(**kwargs) MetaApiResponse[WebhookSubscription][source]

Get webhooks with pagination metadata.

Official documentation: api_public/webhook_subscriptions

Parameters:

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:

Response containing records and pagination metadata.

Return type:

MetaApiResponse[WebhookSubscription]

async get_by_id(webhook_subscription_id: int | str, **kwargs) WebhookSubscription[source]

Get a specific webhook by ID.

Official documentation: api_public/webhook_subscriptions

Parameters:
  • webhook_subscription_id (int | str) – The unique identifier.

  • 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 record.

Return type:

WebhookSubscription

async update(webhook_subscription_id: int | str, data: Mapping[str, Any], **kwargs) WebhookSubscription[source]

Update an existing webhook subscription.

Official documentation: api_public/webhook_subscriptions

Parameters:
  • webhook_subscription_id (int | str) – The unique identifier of the record to update.

  • data (Mapping[str, Any]) – Payload with fields to update (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 record.

Return type:

WebhookSubscription