---
title: "Upsert test event"
method: PATCH
path: "/api/projects/{projectId}/test-events"
tags: ["Test events"]
---

# Upsert test event

`PATCH /api/projects/{projectId}/test-events`

Create a new test event or update an existing one if a matching ID is provided.

## Path parameters

- `projectId` string, uuid, required

## Request body

- object
  - `testEvent` object, required — Test event data to create or update
    - `id` string, uuid, required
    - `name` string, required
    - `context` string, required
    - `category` 'private' | 'shared' | 'global', required
    - `userId` string, uuid, nullable
    - `documentId` string, uuid, nullable

## Response `200`

The created or updated test event

- object — The created or updated test event
  - `id` string, uuid, required — Unique identifier of the test event
  - `name` string, required — Name of the test event
  - `context` string, required — JSON context data for the test event
  - `category` 'private' | 'shared' | 'global', required — Category of the test event (private, shared, or global)
  - `projectId` string, uuid, required — ID of the project this test event belongs to
  - `userId` string, uuid, nullable — ID of the user who owns this test event (for private events)
  - `documentId` string, uuid, nullable — ID of the document this test event is associated with

---

[API](https://skmtc.net/gorules/apis/gorules-agent-api.md) · [All operations](https://skmtc.net/gorules/apis/gorules-agent-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/gorules/gorules-agent-api/versions/52c0773fcd80/schema)
