> ## Documentation Index
> Fetch the complete documentation index at: https://docs.timbrix.mx/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Request Log

Returns one entry of the API request log, with the details that the list leaves out: the caller's `ip`, the `userAgent` and, for failed requests, the `errorBody`.

The `id` is the same value the API returned in the `X-Request-Id` header of that response. If something failed, copy the ID from the header and look it up here.

## Authentication

Accepts **either**:

* An API key (`X-API-Key: sk_...`) with the `read:request-logs` scope — the organization is resolved from the key itself.
* A Supabase Bearer session (`Authorization: Bearer <token>`) with the `X-Organization-Id: <org-id>` header — the authenticated user must be an owner or admin of that organization.

## About `errorBody`

* It is present **only** when `statusCode` is 400 or higher. Successful responses never store a body.
* RFCs found in it are masked as `***RFC***`.
* It holds at most 2 KB. When the body is longer, you get `{ "truncated": true, "preview": "…" }` instead.

## Example Request

```bash theme={null}
curl "https://api.timbrix.mx/request-logs/0f8b2c1e-6a4d-4c43-9d6e-3b1f6a9e7c10" \
  -H "X-API-Key: sk_..."
```

```typescript theme={null}
import { Timbrix } from "@timbrix/sdk"

const client = new Timbrix({ apiKey: "sk_..." })

const log = await client.requestLogs.get("0f8b2c1e-6a4d-4c43-9d6e-3b1f6a9e7c10")
console.log(log.statusCode, log.errorBody)
```

## Example Response

```json theme={null}
{
  "id": "0f8b2c1e-6a4d-4c43-9d6e-3b1f6a9e7c10",
  "createdAt": "2026-10-14T18:32:10.482Z",
  "method": "POST",
  "route": "/invoices",
  "path": "/invoices",
  "statusCode": 400,
  "durationMs": 95,
  "environment": "production",
  "channel": "sdk",
  "authFailure": null,
  "apiKey": {
    "id": "7d3a9c52-1f0e-4a8b-b6c4-2e5d8f9a1b33",
    "name": "Production API Key",
    "keyPreview": "...ab12"
  },
  "ip": "203.0.113.42",
  "userAgent": "@timbrix/sdk",
  "errorBody": {
    "statusCode": 400,
    "message": "Receptor ***RFC*** no es válido",
    "error": "Bad Request"
  }
}
```

## Common Errors

### 401 Unauthorized

Missing or invalid Bearer token / API key.

### 403 Forbidden

The authenticated user is not an owner or admin of the organization, or the API key does not have the `read:request-logs` scope.

### 404 Not Found

The record does not exist, has passed the 30-day retention, or belongs to another organization.


## OpenAPI

````yaml GET /request-logs/{id}
openapi: 3.0.0
info:
  title: Timbrix API
  description: >-
    API de facturación electrónica CFDI 4.0 para México, con servidor OAuth2
    para gestionar organizaciones, miembros y webhooks. Compatible con agentes
    de IA — ver la extensión `x-ai-agent-friendly` en la raíz de esta spec.


    REST API with OAuth2 server for managing organizations, members, and
    webhooks.
  version: '1.0'
  contact: {}
servers: []
security: []
tags:
  - name: organizations
    description: Organization management endpoints
  - name: oauth
    description: OAuth2 authentication and authorization
  - name: webhooks
    description: Webhook configuration and delivery
  - name: users
    description: User information endpoints
  - name: api-keys
    description: API Keys management and validation
  - name: request-logs
    description: API request log
paths:
  /request-logs/{id}:
    get:
      tags:
        - request-logs
      summary: Get one API request, including its error body
      operationId: RequestLogsController_get
      parameters:
        - name: id
          required: true
          in: path
          schema:
            type: string
        - name: X-Organization-Id
          in: header
          description: >-
            Required for Supabase session auth (owner or admin). Ignored with an
            API key.
          required: false
          schema:
            type: string
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RequestLogDetailDto'
        '404':
          description: Not found in this organization
      security:
        - apiKey: []
        - bearer: []
components:
  schemas:
    RequestLogDetailDto:
      type: object
      properties:
        id:
          type: string
          description: También es el header X-Request-Id
        createdAt:
          type: string
        method:
          type: string
        route:
          type: string
          example: /invoices/:uuid
        path:
          type: string
        statusCode:
          type: number
        durationMs:
          type: number
        environment:
          type: string
          enum:
            - sandbox
            - production
          nullable: true
        channel:
          type: object
          nullable: true
        authFailure:
          type: object
          nullable: true
        apiKey:
          nullable: true
          type: object
          allOf:
            - $ref: '#/components/schemas/RequestLogApiKeyDto'
        ip:
          type: object
          nullable: true
        userAgent:
          type: object
          nullable: true
        errorBody:
          type: object
          nullable: true
          description: >-
            Cuerpo del error (solo status ≥ 400), con RFC enmascarados y máximo
            2 KB
      required:
        - id
        - createdAt
        - method
        - route
        - path
        - statusCode
        - durationMs
    RequestLogApiKeyDto:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        keyPreview:
          type: string
          example: ...a1b2
      required:
        - id
        - name
        - keyPreview
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: 'API Key for authentication (format: sk_...)'
    bearer:
      scheme: bearer
      bearerFormat: JWT
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.