Skip to main content
Manage Actors

Get or Create Actor

Return the actor with the given name and key, creating it if it does not exist. This is the HTTP equivalent of client.actor.getOrCreate(key).

The response includes created, which is true when this call created the actor. Gateway endpoints can perform the same lookup inline with the rvt-* selector parameters, so you only need this endpoint when you want the actor_id up front.

PUT https://api.rivet.dev/actors

Examples

Authentication

Send your namespace token as a bearer token in the Authorization header. Every control plane request also requires the namespace query parameter. See Authentication.

Query Parameters

NameTypeRequiredDescription
namespacestringYesName of the namespace to operate in.

Request Body

Content type: application/json.

FieldTypeRequiredDescription
crash_policy"restart" | "sleep" | "destroy"YesWhat happens when the actor crashes. RivetKit defaults to sleep.
datacenterstring | nullNoDatacenter to create the actor in if it does not exist. Defaults to the datacenter serving the request.
inputstring | nullNoBase64url-encoded CBOR input passed to the actor’s createState and onCreate hooks when the actor is created.
keystringYesKey identifying this actor within its name. Multi-part keys are joined with /, see Actor Keys.
namestringYesName of the actor as registered in your RivetKit registry.
runner_name_selectorstringYesPool that runs the actor. RivetKit registers the default pool unless configured otherwise.

Responses

200

FieldTypeDescription
actorobject
actor.actor_idstringUnique ID of the actor.
actor.connectable_tsinteger | nullDenotes when the actor was last connectable. Null if actor is not running.
actor.crash_policy"restart" | "sleep" | "destroy"What happens when the actor crashes.
actor.create_tsintegerDenotes when the actor was first created.
actor.datacenterstringDatacenter the actor is scheduled in.
actor.destroy_tsinteger | nullDenotes when the actor was destroyed.
actor.errorobject | nullError details if the actor failed to start.
actor.keystring | nullActor key. Multi-part keys are joined with /, see Actor Keys.
actor.namestringActor name as registered in your RivetKit registry.
actor.namespace_idstringID of the namespace the actor belongs to.
actor.pending_allocation_tsinteger | nullDenotes when the actor started waiting for an allocation.
actor.reschedule_tsinteger | nullDenotes when the actor will try to allocate again. If this is set, the actor will not attempt to allocate until the given timestamp.
actor.runner_name_selectorstringPool the actor runs on.
actor.sleep_tsinteger | nullDenotes when the actor entered a sleeping state.
actor.start_tsinteger | nullDenotes when the actor was first made connectable. Null if never.
createdbooleantrue if this request created the actor, false if it already existed.
{
  "actor": {
    "actor_id": "00000000-0000-0000-0000-000000000000",
    "connectable_ts": null,
    "crash_policy": "restart",
    "create_ts": 1700000000000,
    "datacenter": "us-east",
    "destroy_ts": null,
    "error": null,
    "key": null,
    "name": "my-actor",
    "namespace_id": "00000000-0000-0000-0000-000000000000",
    "pending_allocation_ts": null,
    "reschedule_ts": null,
    "runner_name_selector": "default",
    "sleep_ts": null,
    "start_ts": null
  },
  "created": false
}