Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

πŸ”₯ Drop the update poll endpoint from the v1 API (#3286)

Luke Vellae07b9866bbaf
diff --git a/apps/docs/api-reference/changelog.mdx b/apps/docs/api-reference/changelog.mdx
index df5fd185d..9bb3d7161 100644
--- a/apps/docs/api-reference/changelog.mdx
+++ b/apps/docs/api-reference/changelog.mdx
@@ -6,7 +6,7 @@ description: "Changes to the API, newest first."
<Update label="v1">
Initial stable release under `/v1`.
-- Create, list, get, update, close and delete polls
+- Create, list, get and delete polls
- Read a poll's results and participants
- Bearer authentication with space API keys
- Per space rate limits with `RateLimit-*` headers
diff --git a/apps/docs/api-reference/errors.mdx b/apps/docs/api-reference/errors.mdx
index 768c158a2..6c3eb41ea 100644
--- a/apps/docs/api-reference/errors.mdx
+++ b/apps/docs/api-reference/errors.mdx
@@ -29,7 +29,6 @@ Every failure is `application/json` with the same shape:
| 403 | `SPACE_NOT_PRO` | The space behind the key has no Pro subscription |
| 404 | `NOT_FOUND` | No route matches the method and path |
| 404 | `POLL_NOT_FOUND` | The poll does not exist or belongs to another space |
-| 422 | `TRANSITION_NOT_AVAILABLE` | The requested status change is not supported |
| 429 | `RATE_LIMIT_EXCEEDED` | A rate limit window is exhausted; see [Rate limits](/api-reference/rate-limits) |
| 503 | `SERVICE_UNAVAILABLE` | Maintenance, or the rate limit store cannot be reached |
| 500 | `INTERNAL_ERROR` | Unexpected failure; the request id is logged |
diff --git a/apps/docs/api-reference/introduction.mdx b/apps/docs/api-reference/introduction.mdx
index 2b3bae279..a04143a5c 100644
--- a/apps/docs/api-reference/introduction.mdx
+++ b/apps/docs/api-reference/introduction.mdx
@@ -3,7 +3,7 @@ title: "Introduction"
description: "Create and manage scheduling polls from your own systems."
---
-The Rallly API lets you create polls, read their options, results and participants, and close or delete them from your own tools. Every request is scoped to one space: the API key identifies the space, and every poll you create or read belongs to it.
+The Rallly API lets you create polls, read their options, results and participants, and delete them from your own tools. Every request is scoped to one space: the API key identifies the space, and every poll you create or read belongs to it.
## Availability
diff --git a/apps/docs/api-reference/openapi.json b/apps/docs/api-reference/openapi.json
index bd424db00..5aee425d8 100644
--- a/apps/docs/api-reference/openapi.json
+++ b/apps/docs/api-reference/openapi.json
@@ -2,7 +2,7 @@
"openapi": "3.1.0",
"info": {
"title": "Rallly API",
- "description": "## Versioning\n\n`v1` is stable. Additive changes (new endpoints, new optional fields) may land on this path at any time; breaking changes only arrive under a new version prefix.\n\n## Rate limits\n\nAll endpoints share two limits per space: **60 requests per minute** and **5000 requests per day**. Both are fixed windows that open with the first request and reset when they expire. Both limits are per space, not per API key, so creating additional keys does not increase throughput.\n\nEvery response from an authenticated request includes the standard `RateLimit-*` headers. Responses sent before the limiter runs (`401`, `403`, and the maintenance `503`) do not. `RateLimit-Policy` lists both limits; `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset` describe whichever limit is closest to being exhausted. When either limit is exceeded the API responds with `429 Too Many Requests`, a `RATE_LIMIT_EXCEEDED` error body, and a `Retry-After` header indicating how many seconds to wait before retrying.\n\nIf the rate limit store cannot be reached the API fails closed and responds with `503 Service Unavailable`, a `SERVICE_UNAVAILABLE` error body, and a `Retry-After` header.\n\n## Dates and times\n\nEvery poll has a `kind`. A `date` poll offers calendar days: each option carries a `date` in `YYYY-MM-DD` format, which is a floating date with no time component and no timezone, so never convert it through a timezone. A `time` poll offers time slots: each option carries a `startTime` as an ISO 8601 instant in UTC and a `duration` in minutes; convert `startTime` into the poll's `timeZone` (or the viewer's) for display. Timestamps such as `createdAt` and `updatedAt` are always ISO 8601 instants in UTC.\n\n## Request bodies\n\nRequest bodies are validated strictly: a field that is not part of the documented schema is rejected with `VALIDATION_ERROR` rather than ignored, so a misspelt setting never silently falls back to its default.\n\n## Enums\n\nVote types are an open set. The built-in values are `yes`, `ifNeedBe` and `no`; new types may be added without a version change, so clients must tolerate values they do not recognise. `status` and `kind` are closed sets.\n\n## Lists\n\nEvery list endpoint returns the items in `data` and a `nextCursor` beside it. Pass `nextCursor` as the `cursor` query parameter to fetch the next page; it is `null` on the last page.\n\n## Errors\n\nEvery failure is `application/json` with the shape `{ \"error\": { \"code\", \"message\" } }`. `code` is stable and safe to branch on; `message` is human-readable and may change. `VALIDATION_ERROR` messages name each offending field.\n\n| Status | Code | When |\n| --- | --- | --- |\n| 400 | `VALIDATION_ERROR` | The body or query string did not match the schema, contained an unknown field, or the body was not valid JSON |\n| 400 | `INVALID_AUTHORIZATION_HEADER` | The `Authorization` header is not `Bearer <key>` |\n| 400 | `ORGANIZER_NOT_MEMBER` | The organizer email is not a member of the space |\n| 400 | `TOO_MANY_OPTIONS` | More than the maximum number of poll options |\n| 400 | `INAPPROPRIATE_CONTENT` | The title, description or location was flagged by content moderation |\n| 401 | `UNAUTHORIZED` | The API key is missing, invalid, expired or revoked, or its owner is banned |\n| 403 | `SPACE_NOT_PRO` | The space behind the key has no Pro subscription |\n| 404 | `NOT_FOUND` | No route matches the method and path |\n| 404 | `POLL_NOT_FOUND` | The poll does not exist or belongs to another space |\n| 422 | `TRANSITION_NOT_AVAILABLE` | The requested status change is not supported |\n| 429 | `RATE_LIMIT_EXCEEDED` | A rate limit window is exhausted |\n| 503 | `SERVICE_UNAVAILABLE` | Maintenance, or the rate limit store cannot be reached |\n| 500 | `INTERNAL_ERROR` | Unexpected failure; the request id is logged |",
+ "description": "## Versioning\n\n`v1` is stable. Additive changes (new endpoints, new optional fields) may land on this path at any time; breaking changes only arrive under a new version prefix.\n\n## Rate limits\n\nAll endpoints share two limits per space: **60 requests per minute** and **5000 requests per day**. Both are fixed windows that open with the first request and reset when they expire. Both limits are per space, not per API key, so creating additional keys does not increase throughput.\n\nEvery response from an authenticated request includes the standard `RateLimit-*` headers. Responses sent before the limiter runs (`401`, `403`, and the maintenance `503`) do not. `RateLimit-Policy` lists both limits; `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset` describe whichever limit is closest to being exhausted. When either limit is exceeded the API responds with `429 Too Many Requests`, a `RATE_LIMIT_EXCEEDED` error body, and a `Retry-After` header indicating how many seconds to wait before retrying.\n\nIf the rate limit store cannot be reached the API fails closed and responds with `503 Service Unavailable`, a `SERVICE_UNAVAILABLE` error body, and a `Retry-After` header.\n\n## Dates and times\n\nEvery poll has a `kind`. A `date` poll offers calendar days: each option carries a `date` in `YYYY-MM-DD` format, which is a floating date with no time component and no timezone, so never convert it through a timezone. A `time` poll offers time slots: each option carries a `startTime` as an ISO 8601 instant in UTC and a `duration` in minutes; convert `startTime` into the poll's `timeZone` (or the viewer's) for display. Timestamps such as `createdAt` and `updatedAt` are always ISO 8601 instants in UTC.\n\n## Request bodies\n\nRequest bodies are validated strictly: a field that is not part of the documented schema is rejected with `VALIDATION_ERROR` rather than ignored, so a misspelt setting never silently falls back to its default.\n\n## Enums\n\nVote types are an open set. The built-in values are `yes`, `ifNeedBe` and `no`; new types may be added without a version change, so clients must tolerate values they do not recognise. `status` and `kind` are closed sets.\n\n## Lists\n\nEvery list endpoint returns the items in `data` and a `nextCursor` beside it. Pass `nextCursor` as the `cursor` query parameter to fetch the next page; it is `null` on the last page.\n\n## Errors\n\nEvery failure is `application/json` with the shape `{ \"error\": { \"code\", \"message\" } }`. `code` is stable and safe to branch on; `message` is human-readable and may change. `VALIDATION_ERROR` messages name each offending field.\n\n| Status | Code | When |\n| --- | --- | --- |\n| 400 | `VALIDATION_ERROR` | The body or query string did not match the schema, contained an unknown field, or the body was not valid JSON |\n| 400 | `INVALID_AUTHORIZATION_HEADER` | The `Authorization` header is not `Bearer <key>` |\n| 400 | `ORGANIZER_NOT_MEMBER` | The organizer email is not a member of the space |\n| 400 | `TOO_MANY_OPTIONS` | More than the maximum number of poll options |\n| 400 | `INAPPROPRIATE_CONTENT` | The title, description or location was flagged by content moderation |\n| 401 | `UNAUTHORIZED` | The API key is missing, invalid, expired or revoked, or its owner is banned |\n| 403 | `SPACE_NOT_PRO` | The space behind the key has no Pro subscription |\n| 404 | `NOT_FOUND` | No route matches the method and path |\n| 404 | `POLL_NOT_FOUND` | The poll does not exist or belongs to another space |\n| 429 | `RATE_LIMIT_EXCEEDED` | A rate limit window is exhausted |\n| 503 | `SERVICE_UNAVAILABLE` | Maintenance, or the rate limit store cannot be reached |\n| 500 | `INTERNAL_ERROR` | Unexpected failure; the request id is logged |",
"version": "1.0.0"
},
"servers": [
@@ -656,20 +656,6 @@
"nextCursor"
]
},
- "PatchPollInput": {
- "type": "object",
- "properties": {
- "status": {
- "description": "The status to transition the poll to. Only `closed` is currently accepted; the other statuses are reserved for future transitions.",
- "example": "closed",
- "$ref": "#/components/schemas/PollStatus"
- }
- },
- "required": [
- "status"
- ],
- "additionalProperties": false
- },
"OptionResult": {
"anyOf": [
{
@@ -1387,143 +1373,6 @@
}
]
},
- "patch": {
- "operationId": "patchV1PollsByPollId",
- "tags": [
- "Polls"
- ],
- "summary": "Update a poll",
- "description": "Updates a poll's status. Currently the only supported transition is closing a poll by sending `{ \"status\": \"closed\" }`.\n\nClose a poll once you have picked a date or the poll is no longer needed. Closing is non-destructive β€” the poll and its responses are preserved β€” but the results become final and participants can no longer vote. Consumers polling `GET /polls/:pollId/results` should remove closed polls from their queues.\n\nClosing is idempotent: closing an already-closed poll returns a `200` with the poll unchanged. The other statuses (`open`, `scheduled`, `canceled`) are not available via the API and return `422`.",
- "security": [
- {
- "bearerAuth": []
- }
- ],
- "responses": {
- "200": {
- "description": "Poll updated successfully",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/PollResponse"
- }
- }
- }
- },
- "401": {
- "description": "The API key is missing, invalid, expired or revoked, or its owner is banned. Includes a `WWW-Authenticate` header.",
- "headers": {
- "WWW-Authenticate": {
- "description": "The bearer challenge, per RFC 6750.",
- "schema": {
- "type": "string"
- }
- }
- },
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ErrorResponse"
- }
- }
- }
- },
- "403": {
- "description": "The space associated with the API key does not have a Pro subscription",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ErrorResponse"
- }
- }
- }
- },
- "404": {
- "description": "Poll not found",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ErrorResponse"
- }
- }
- }
- },
- "422": {
- "description": "The requested status transition is not available",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ErrorResponse"
- }
- }
- }
- },
- "429": {
- "description": "Rate limit exceeded. Includes a `Retry-After` header indicating how many seconds to wait before retrying.",
- "headers": {
- "Retry-After": {
- "description": "Seconds to wait before retrying the request.",
- "schema": {
- "type": "integer"
- }
- }
- },
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ErrorResponse"
- }
- }
- }
- },
- "503": {
- "description": "The API is temporarily unavailable, for maintenance or because the rate limit store cannot be reached. Includes a `Retry-After` header. Maintenance responses are sent before the rate limiter runs and carry no `RateLimit-*` headers.",
- "headers": {
- "Retry-After": {
- "description": "Seconds to wait before retrying the request.",
- "schema": {
- "type": "integer"
- }
- }
- },
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ErrorResponse"
- }
- }
- }
- }
- },
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/PatchPollInput"
- },
- "examples": {
- "Close the poll": {
- "summary": "Close a poll",
- "description": "Set `status` to `closed` once you have picked a date or no longer need the poll. Closing is idempotent and makes the results final.",
- "value": {
- "status": "closed"
- }
- }
- }
- }
- }
- },
- "parameters": [
- {
- "schema": {
- "type": "string"
- },
- "in": "path",
- "name": "pollId",
- "required": true
- }
- ]
- },
"delete": {
"operationId": "deleteV1PollsByPollId",
"tags": [
diff --git a/apps/docs/docs.json b/apps/docs/docs.json
index 77e8fec7a..c09b4d9f0 100644
--- a/apps/docs/docs.json
+++ b/apps/docs/docs.json
@@ -93,7 +93,6 @@
"POST /v1/polls",
"GET /v1/polls",
"GET /v1/polls/{pollId}",
- "PATCH /v1/polls/{pollId}",
"DELETE /v1/polls/{pollId}",
"GET /v1/polls/{pollId}/results",
"GET /v1/polls/{pollId}/participants"
diff --git a/apps/web/src/app/api/v1/[...route]/route.test.ts b/apps/web/src/app/api/v1/[...route]/route.test.ts
index e2a60b45b..b98b414ac 100644
--- a/apps/web/src/app/api/v1/[...route]/route.test.ts
+++ b/apps/web/src/app/api/v1/[...route]/route.test.ts
@@ -5,7 +5,6 @@ vi.mock("server-only", () => ({}));
const mockDeletePoll = vi.fn();
const mockCreatePoll = vi.fn();
-const mockClosePoll = vi.fn();
const mockGetPollResults = vi.fn();
const mockGetPollParticipants = vi.fn();
const mockListPolls = vi.fn();
@@ -21,7 +20,6 @@ vi.mock("@/features/moderation/mutations", () => ({
vi.mock("@/features/poll/mutations", () => ({
deletePoll: (...args: unknown[]) => mockDeletePoll(...args),
createPoll: (...args: unknown[]) => mockCreatePoll(...args),
- closePoll: (...args: unknown[]) => mockClosePoll(...args),
}));
vi.mock("@/features/poll/data", () => ({
@@ -87,10 +85,7 @@ import { MAX_SLOT_GENERATION_DAYS } from "@/lib/datetime/slot-generator";
import { redis } from "@/lib/kv";
import type { FakeRedis } from "../../middleware/fake-redis";
import { RATE_LIMIT_PER_MINUTE } from "../../middleware/rate-limit";
-import {
- createPollRequestExamples,
- patchPollRequestExamples,
-} from "../examples";
+import { createPollRequestExamples } from "../examples";
import {
createPollInputSchema,
deletePollSuccessResponseSchema,
@@ -1628,25 +1623,6 @@ describe("API v1 - /polls", () => {
}
});
- it("should document the close poll transition on PATCH /polls/{pollId}", async () => {
- const res = await app.request("/v1/openapi");
-
- expect(res.status).toBe(200);
- const json = await res.json();
- const operation = json.paths["/v1/polls/{pollId}"].patch;
-
- expect(operation.summary).toBeDefined();
- expect(operation.description).toContain("closed");
- expect(Object.keys(operation.responses)).toEqual(
- expect.arrayContaining(["200", "403", "404", "422", "429"]),
- );
-
- const media = operation.requestBody.content["application/json"];
- expect(Object.keys(media.examples)).toEqual(
- Object.keys(patchPollRequestExamples),
- );
- });
-
it("should emit schema descriptions, examples and named components", async () => {
const res = await app.request("/v1/openapi");
@@ -1720,10 +1696,6 @@ describe("API v1 - /polls", () => {
$ref: pollStatusRef,
description: expect.stringContaining("close automatically"),
});
- expect(schemas.PatchPollInput.properties.status).toMatchObject({
- $ref: pollStatusRef,
- example: "closed",
- });
expect(json.paths["/v1/polls"].get.parameters).toContainEqual(
expect.objectContaining({
name: "status",
@@ -1778,7 +1750,6 @@ describe("API v1 - /polls", () => {
expect(schemas.Poll.properties[key]).toBeDefined();
}
}
- expect(schemas.PatchPollInput.additionalProperties).toBe(false);
expect(schemas.Poll.properties.user).toBeUndefined();
expect(schemas.Poll.properties.organizer).toMatchObject({
anyOf: expect.arrayContaining([
@@ -1822,157 +1793,6 @@ describe("API v1 - /polls", () => {
});
});
- describe("Patch poll (close)", () => {
- const closedPoll = {
- id: "test-poll-id",
- title: "Test Poll",
- description: null,
- location: null,
- timeZone: null,
- status: "closed",
- kind: "date",
- createdAt: new Date("2025-01-10T12:00:00Z"),
- updatedAt: new Date("2025-01-10T12:00:00Z"),
- requireParticipantEmail: false,
- hideParticipants: false,
- hideScores: false,
- disableComments: true,
- allowTentativeVotes: true,
- participantCount: 4,
- user: {
- id: "test-user-id",
- name: "Test User",
- email: "[email protected]",
- image: null,
- },
- options: [],
- };
-
- it("should close an open poll", async () => {
- mockClosePoll.mockResolvedValue(closedPoll);
-
- const res = await app.request("/v1/polls/test-poll-id", {
- method: "PATCH",
- headers: {
- Authorization: `Bearer ${testApiKey}`,
- "Content-Type": "application/json",
- },
- body: JSON.stringify({ status: "closed" }),
- });
-
- expect(res.status).toBe(200);
- const json = await res.json();
- expectMatchesContract(pollResponseSchema, json);
- expect(json.data.id).toBe("test-poll-id");
- expect(json.data.status).toBe("closed");
-
- expect(mockClosePoll).toHaveBeenCalledWith({
- pollId: "test-poll-id",
- spaceId: "test-space-id",
- });
- });
-
- it("should be idempotent when the poll is already closed", async () => {
- mockClosePoll.mockResolvedValue(closedPoll);
-
- const res = await app.request("/v1/polls/test-poll-id", {
- method: "PATCH",
- headers: {
- Authorization: `Bearer ${testApiKey}`,
- "Content-Type": "application/json",
- },
- body: JSON.stringify({ status: "closed" }),
- });
-
- expect(res.status).toBe(200);
- const json = await res.json();
- expect(json.data.status).toBe("closed");
- });
-
- it("should return 404 when the poll is not found", async () => {
- mockClosePoll.mockResolvedValue(null);
-
- const res = await app.request("/v1/polls/nonexistent-poll", {
- method: "PATCH",
- headers: {
- Authorization: `Bearer ${testApiKey}`,
- "Content-Type": "application/json",
- },
- body: JSON.stringify({ status: "closed" }),
- });
-
- expect(res.status).toBe(404);
- const json = await res.json();
- expect(json.error.code).toBe("POLL_NOT_FOUND");
- expect(mockClosePoll).toHaveBeenCalled();
- });
-
- it.each([
- "open",
- "scheduled",
- "canceled",
- ])("should return 422 when transitioning to %s", async (status) => {
- const res = await app.request("/v1/polls/test-poll-id", {
- method: "PATCH",
- headers: {
- Authorization: `Bearer ${testApiKey}`,
- "Content-Type": "application/json",
- },
- body: JSON.stringify({ status }),
- });
-
- expect(res.status).toBe(422);
- const json = await res.json();
- expect(json.error.code).toBe("TRANSITION_NOT_AVAILABLE");
- expect(mockClosePoll).not.toHaveBeenCalled();
- });
-
- it("should reject unknown fields in the patch body", async () => {
- const res = await app.request("/v1/polls/test-poll-id", {
- method: "PATCH",
- headers: {
- Authorization: `Bearer ${testApiKey}`,
- "Content-Type": "application/json",
- },
- body: JSON.stringify({ status: "closed", title: "Renamed" }),
- });
-
- const json = await expectErrorEnvelope(res, {
- status: 400,
- code: "VALIDATION_ERROR",
- });
- expect(json.error.message).toContain("title");
- expect(mockClosePoll).not.toHaveBeenCalled();
- });
-
- it("should return 400 for an unknown status value", async () => {
- const res = await app.request("/v1/polls/test-poll-id", {
- method: "PATCH",
- headers: {
- Authorization: `Bearer ${testApiKey}`,
- "Content-Type": "application/json",
- },
- body: JSON.stringify({ status: "archived" }),
- });
-
- expect(res.status).toBe(400);
- expect(mockClosePoll).not.toHaveBeenCalled();
- });
-
- it("should return 401 without authorization", async () => {
- const res = await app.request("/v1/polls/test-poll-id", {
- method: "PATCH",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({ status: "closed" }),
- });
-
- expect(res.status).toBe(401);
- expect(mockClosePoll).not.toHaveBeenCalled();
- });
- });
-
describe("Delete poll", () => {
it("should delete a poll", async () => {
mockDeletePoll.mockResolvedValue({ id: "test-poll-id" });
@@ -3082,21 +2902,6 @@ describe("API v1 - /polls", () => {
expect(mockListPolls).not.toHaveBeenCalled();
});
- it("should return 400 VALIDATION_ERROR as JSON for a PATCH body that fails validation", async () => {
- const res = await app.request("/v1/polls/test-poll-id", {
- method: "PATCH",
- headers: { ...authed, "Content-Type": "application/json" },
- body: JSON.stringify({ status: "archived" }),
- });
-
- const json = await expectErrorEnvelope(res, {
- status: 400,
- code: "VALIDATION_ERROR",
- });
- expect(json.error.message).toMatch(/^status: /);
- expect(json).not.toHaveProperty("data");
- });
-
it("should return 400 VALIDATION_ERROR as JSON for a malformed JSON body", async () => {
const res = await app.request("/v1/polls", {
method: "POST",
@@ -3168,7 +2973,6 @@ describe("API v1 - /polls", () => {
"POLL_NOT_FOUND",
"ORGANIZER_NOT_MEMBER",
"TOO_MANY_OPTIONS",
- "TRANSITION_NOT_AVAILABLE",
"SERVICE_UNAVAILABLE",
"INTERNAL_ERROR",
]) {
diff --git a/apps/web/src/app/api/v1/[...route]/route.ts b/apps/web/src/app/api/v1/[...route]/route.ts
index c02d0def6..969e69dd7 100644
--- a/apps/web/src/app/api/v1/[...route]/route.ts
+++ b/apps/web/src/app/api/v1/[...route]/route.ts
@@ -17,7 +17,7 @@ import {
getPollWithOptions,
listPolls,
} from "@/features/poll/data";
-import { closePoll, createPoll, deletePoll } from "@/features/poll/mutations";
+import { createPoll, deletePoll } from "@/features/poll/mutations";
import { getSpaceMemberByEmail } from "@/features/space/member/data";
import type { SpaceTier } from "@/features/space/schema";
import type { AuthorizedSpaceId } from "@/features/space/types";
@@ -38,10 +38,7 @@ import {
rateLimit,
} from "../../middleware/rate-limit";
import { wideEvent } from "../../middleware/wide-event";
-import {
- createPollRequestExamples,
- patchPollRequestExamples,
-} from "../examples";
+import { createPollRequestExamples } from "../examples";
import {
createPollInputSchema,
deletePollSuccessResponseSchema,
@@ -51,7 +48,6 @@ import {
listParticipantsQuerySchema,
listPollsQuerySchema,
listPollsSuccessResponseSchema,
- patchPollInputSchema,
pollResponseSchema,
} from "../schemas";
@@ -311,7 +307,6 @@ async function buildOpenApiSpec() {
"| 403 | `SPACE_NOT_PRO` | The space behind the key has no Pro subscription |",
"| 404 | `NOT_FOUND` | No route matches the method and path |",
"| 404 | `POLL_NOT_FOUND` | The poll does not exist or belongs to another space |",
- "| 422 | `TRANSITION_NOT_AVAILABLE` | The requested status change is not supported |",
"| 429 | `RATE_LIMIT_EXCEEDED` | A rate limit window is exhausted |",
"| 503 | `SERVICE_UNAVAILABLE` | Maintenance, or the rate limit store cannot be reached |",
"| 500 | `INTERNAL_ERROR` | Unexpected failure; the request id is logged |",
@@ -343,15 +338,6 @@ async function buildOpenApiSpec() {
}
}
- const patchPollRequestBody =
- spec.paths["/v1/polls/{pollId}"]?.patch?.requestBody;
- if (patchPollRequestBody && "content" in patchPollRequestBody) {
- const media = patchPollRequestBody.content?.["application/json"];
- if (media) {
- media.examples = patchPollRequestExamples;
- }
- }
-
return spec;
}
@@ -780,84 +766,6 @@ app.get(
},
);
-app.patch(
- "/polls/:pollId",
- spaceApiKeyAuth,
- rateLimit,
- describeRoute({
- tags: ["Polls"],
- summary: "Update a poll",
- description: [
- 'Updates a poll\'s status. Currently the only supported transition is closing a poll by sending `{ "status": "closed" }`.',
- "",
- "Close a poll once you have picked a date or the poll is no longer needed. Closing is non-destructive β€” the poll and its responses are preserved β€” but the results become final and participants can no longer vote. Consumers polling `GET /polls/:pollId/results` should remove closed polls from their queues.",
- "",
- "Closing is idempotent: closing an already-closed poll returns a `200` with the poll unchanged. The other statuses (`open`, `scheduled`, `canceled`) are not available via the API and return `422`.",
- ].join("\n"),
- security: [{ bearerAuth: [] }],
- responses: {
- 200: {
- description: "Poll updated successfully",
- content: {
- "application/json": {
- schema: resolver(pollResponseSchema),
- },
- },
- },
- 401: unauthorizedResponse,
- 403: spaceNotProResponse,
- 429: rateLimitExceededResponse,
- 503: serviceUnavailableResponse,
- 404: {
- description: "Poll not found",
- content: {
- "application/json": {
- schema: resolver(errorResponseSchema),
- },
- },
- },
- 422: {
- description: "The requested status transition is not available",
- content: {
- "application/json": {
- schema: resolver(errorResponseSchema),
- },
- },
- },
- },
- }),
- validator("json", patchPollInputSchema, validationHook),
- async (c) => {
- const { pollId } = c.req.param();
- const { status } = c.req.valid("json");
- const { spaceId } = c.get("apiAuth");
-
- if (status !== "closed") {
- return c.json(
- apiError(
- "TRANSITION_NOT_AVAILABLE",
- `Transitioning a poll to "${status}" is not available via the API. Only "closed" is supported.`,
- ),
- 422,
- );
- }
-
- const poll = await closePoll({ pollId, spaceId });
-
- if (!poll) {
- return c.json(
- apiError(
- "POLL_NOT_FOUND",
- "Poll not found or does not belong to this space.",
- ),
- 404,
- );
- }
-
- return c.json(pollResponseSchema.parse(toPollResponseBody(poll)));
- },
-);
-
app.get(
"/polls/:pollId/results",
spaceApiKeyAuth,
diff --git a/apps/web/src/app/api/v1/examples.ts b/apps/web/src/app/api/v1/examples.ts
index 068e431e9..45d057509 100644
--- a/apps/web/src/app/api/v1/examples.ts
+++ b/apps/web/src/app/api/v1/examples.ts
@@ -1,8 +1,7 @@
import type * as z from "zod";
-import type { createPollInputSchema, patchPollInputSchema } from "./schemas";
+import type { createPollInputSchema } from "./schemas";
type CreatePollInput = z.input<typeof createPollInputSchema>;
-type PatchPollInput = z.input<typeof patchPollInputSchema>;
export const createPollRequestExamples = {
"Date poll": {
@@ -79,14 +78,3 @@ export const createPollRequestExamples = {
} satisfies CreatePollInput,
},
};
-
-export const patchPollRequestExamples = {
- "Close the poll": {
- summary: "Close a poll",
- description:
- "Set `status` to `closed` once you have picked a date or no longer need the poll. Closing is idempotent and makes the results final.",
- value: {
- status: "closed",
- } satisfies PatchPollInput,
- },
-};
diff --git a/apps/web/src/app/api/v1/schemas.ts b/apps/web/src/app/api/v1/schemas.ts
index b6b7702a0..cab7934ad 100644
--- a/apps/web/src/app/api/v1/schemas.ts
+++ b/apps/web/src/app/api/v1/schemas.ts
@@ -465,16 +465,6 @@ export const pollResponseSchema = z
})
.meta({ id: "PollResponse" });
-export const patchPollInputSchema = z
- .strictObject({
- status: pollStatusSchema.meta({
- description:
- "The status to transition the poll to. Only `closed` is currently accepted; the other statuses are reserved for future transitions.",
- example: "closed",
- }),
- })
- .meta({ id: "PatchPollInput" });
-
export const listPollsQuerySchema = z.object({
status: pollStatusSchema.optional().meta({
description: "Filter polls by status. Omit to include all statuses.",