Events

Events are a log of changes in API object state. Use them to handle asynchronous updates from Bias in your application code.

The Event object

Name
object
Type
"event",
Description
Literal representing the object’s type.
Name
id
Type
string,
Description
Unique identifier for the object.
Name
live
Type
boolean,
Description
Has the value true if the object exists in a production environment or the value false if the object exists in a sandbox environment.
Name
created_at
Type
integer,
Description
Time at which the object was created. Measured in milliseconds since the Unix epoch.
Name
previous_state
Type
CheckoutSession, Customer, Discount, Dispute, File, object, Payment, PaymentMethod, Price, Product, or Refund or null,
Description
The full object state before the event occurred.
Name
request
Type
string or object or null,
Description
Expandable. The request, if any, that triggered the event.
Properties
Name
state
Type
CheckoutSession, Customer, Discount, Dispute, File, object, Payment, PaymentMethod, Price, Product, or Refund or null,
Description
The full object state after the event occurred.
Name
type
Type
enum,
Description
The type of event that occurred. Follows the format of object.action.

The Event object

{
  "object": "event",
  "live": false,
  "id": "event_I4WDb42QLgdAVoESZlGJY3",
  "created_at": 1750000000000,
  "state": {
    "object": "customer",
    "id": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
    "live": false,
    "created_at": 1750000000000,
    "updated_at": 1750000000000,
    "deleted": false,
    "name": "John Doe",
    "email": "john@bias.dev",
    "phone": null,
    "metadata": {}
  },
  "previous_state": null,
  "request": "req_N6uUqAC2SFJmLKvAQbcEn3",
  "type": "customer.created"
}

Get a event

Retrieve a event by its ID.

Optional parameters

Name
expand
Type
object,
Description
Optional object that allows you to expand certain ID fields to include related resources.
Properties

Returns

Returns the event object.

Retrieve a event

const event = await bias.events.get("id");

Response example

{
  "object": "event",
  "live": false,
  "id": "event_I4WDb42QLgdAVoESZlGJY3",
  "created_at": 1750000000000,
  "state": {
    "object": "customer",
    "id": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
    "live": false,
    "created_at": 1750000000000,
    "updated_at": 1750000000000,
    "deleted": false,
    "name": "John Doe",
    "email": "john@bias.dev",
    "phone": null,
    "metadata": {}
  },
  "previous_state": null,
  "request": "req_N6uUqAC2SFJmLKvAQbcEn3",
  "type": "customer.created"
}

List all events

Retrieve a paginated list of events or stream them as they come in.

Optional parameters

Name
expand
Type
object,
Properties
Name
ending_before
Type
string,
Description
A cursor for use in pagination. ending_before is an object ID that results will end before. Used to move backward through the list.
Name
starting_after
Type
string,
Description
A cursor for use in pagination. starting_after is an object ID that results will start after. Used to move forward through the list.
Name
limit
Type
number, at least 1, at most 1000, default is 50
Description
Maximum number of objects to return.
Name
stream
Type
boolean,
Description
Stream events matching the provided parameters as they are created. If true, the response will be a stream of events, separated by a newline. Space characters are sent periodically to keep the stream alive.
Name
filters
Type
object, object, or object,
Description
Filters to apply to the list. Combine multiple conditions with and and or.
Properties

Returns

Returns a list of event objects.

List all events

const event = await bias.events.list();

Response example

{
  "object": "list",
  "items": {
    "object": "event",
    "live": false,
    "id": "event_I4WDb42QLgdAVoESZlGJY3",
    "created_at": 1750000000000,
    "state": {
      "object": "customer",
      "id": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
      "live": false,
      "created_at": 1750000000000,
      "updated_at": 1750000000000,
      "deleted": false,
      "name": "John Doe",
      "email": "john@bias.dev",
      "phone": null,
      "metadata": {}
    },
    "previous_state": null,
    "request": "req_N6uUqAC2SFJmLKvAQbcEn3",
    "type": "customer.created"
  },
  "has_more": false
}