From 247085248b5140e5b4faba88e54563189f0c0c96 Mon Sep 17 00:00:00 2001 From: Jonathan Pedoeem Date: Tue, 24 Feb 2026 13:11:05 -0500 Subject: [PATCH] Add documentation for GET /api/public/v2/request/{request_id} endpoint - Add OpenAPI spec for the new endpoint in openapi.json - Add reference/get-request.mdx documentation page - Add to Tracking group in mint.json navigation - Add to REST API reference index - Link from request-id feature docs Co-Authored-By: Claude Opus 4.6 --- features/prompt-history/request-id.mdx | 2 +- mint.json | 1 + openapi.json | 119 +++++++++++++++++++++++++ reference/get-request.mdx | 60 +++++++++++++ reference/rest-api-reference.mdx | 1 + 5 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 reference/get-request.mdx diff --git a/features/prompt-history/request-id.mdx b/features/prompt-history/request-id.mdx index 75eb3de..225995f 100644 --- a/features/prompt-history/request-id.mdx +++ b/features/prompt-history/request-id.mdx @@ -5,7 +5,7 @@ icon: "id-card" Every PromptLayer log has a unique PromptLayer Request ID (`pl_id`). -All tracking in PromptLayer is based on the `pl_request_id`. This identifier is needed to enrich logs with [metadata](/features/prompt-history/metadata), [scores](/features/prompt-history/scoring-requests), [associated prompt templates](/features/prompt-history/tracking-templates), and more. +All tracking in PromptLayer is based on the `pl_request_id`. This identifier is needed to enrich logs with [metadata](/features/prompt-history/metadata), [scores](/features/prompt-history/scoring-requests), [associated prompt templates](/features/prompt-history/tracking-templates), and more. You can also use it to [retrieve the full request payload](/reference/get-request) as a prompt blueprint. You can quickly grab a request ID from the web UI as shown below. diff --git a/mint.json b/mint.json index 9bf020e..28202be 100644 --- a/mint.json +++ b/mint.json @@ -150,6 +150,7 @@ { "group": "Tracking", "pages": [ + "reference/get-request", "reference/log-request", "reference/track-prompt", "reference/track-score", diff --git a/openapi.json b/openapi.json index 70e60f5..c2587af 100644 --- a/openapi.json +++ b/openapi.json @@ -2041,6 +2041,125 @@ } } }, + "/api/public/v2/request/{request_id}": { + "get": { + "summary": "Get Request", + "operationId": "getRequest", + "tags": [ + "tracking" + ], + "parameters": [ + { + "name": "X-API-KEY", + "in": "header", + "required": true, + "schema": { + "type": "string" + }, + "description": "API key for authentication." + }, + { + "name": "request_id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "minimum": 1 + }, + "description": "The ID of the request to retrieve." + } + ], + "responses": { + "200": { + "description": "Successfully retrieved request as a prompt blueprint.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "success": { + "type": "boolean", + "description": "Indicates the request was successful." + }, + "prompt_blueprint": { + "type": "object", + "description": "The request converted to a prompt blueprint format.", + "properties": { + "prompt_template": { + "type": "object", + "description": "The prompt template with type and messages." + }, + "metadata": { + "type": "object", + "description": "Metadata including model provider, name, and parameters." + }, + "inference_client_name": { + "type": "string", + "nullable": true, + "description": "The inference client name if one was used." + } + } + }, + "request_id": { + "type": "integer", + "description": "The ID of the request." + }, + "provider": { + "type": "string", + "description": "The LLM provider (e.g. openai, anthropic)." + }, + "model": { + "type": "string", + "description": "The model name (e.g. gpt-4, claude-3-sonnet)." + } + } + } + } + } + }, + "401": { + "description": "Authentication failed.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "403": { + "description": "Invalid workspace.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "404": { + "description": "Request not found.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "500": { + "description": "Internal server error.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, "/api/public/v2/evaluations": { "get": { "summary": "List Evaluations", diff --git a/reference/get-request.mdx b/reference/get-request.mdx new file mode 100644 index 0000000..ff0a6f9 --- /dev/null +++ b/reference/get-request.mdx @@ -0,0 +1,60 @@ +--- +title: "Get Request" +openapi: "GET /api/public/v2/request/{request_id}" +description: "Retrieve a request's payload as a prompt blueprint." +--- + +Retrieve the full payload of a logged request by its ID, returned as a [prompt blueprint](/running-requests/prompt-blueprints). This is useful for: + +- **Request replay**: Re-run a request with the same input and parameters +- **Debugging**: Inspect the exact prompt and model configuration used +- **Dataset creation**: Extract request data for use in evaluations + +The response includes the prompt blueprint (input messages, model configuration, and parameters) along with the provider and model used. + +### Authentication + +This endpoint requires API key authentication via the `X-API-KEY` header, or JWT authentication via the `Authorization: Bearer` header. + +### Example + +```bash +curl -H "X-API-KEY: your_api_key" \ + https://api.promptlayer.com/api/public/v2/request/12345 +``` + +### Response + +```json +{ + "success": true, + "prompt_blueprint": { + "prompt_template": { + "type": "chat", + "messages": [ + { + "role": "user", + "content": [{ "type": "text", "text": "Hello, world!" }] + } + ] + }, + "metadata": { + "model": { + "provider": "openai", + "name": "gpt-4", + "parameters": {} + } + }, + "inference_client_name": null + }, + "request_id": 12345, + "provider": "openai", + "model": "gpt-4" +} +``` + +### Related + +- [Request IDs](/features/prompt-history/request-id) - How to obtain request IDs +- [Prompt Blueprints](/running-requests/prompt-blueprints) - Understanding the blueprint format +- [Log Request](/reference/log-request) - Log new requests diff --git a/reference/rest-api-reference.mdx b/reference/rest-api-reference.mdx index 2a8e569..6633355 100644 --- a/reference/rest-api-reference.mdx +++ b/reference/rest-api-reference.mdx @@ -23,6 +23,7 @@ Here are the calls you can make via our REST API: ### Tracking +- [Get Request](/reference/get-request) - [Log Request](/reference/log-request) - [Track Prompt](/reference/track-prompt) - [Track Score](/reference/track-score)