---
title: Request and Response Examples
description: Learn how to document APIs with RequestExample and ResponseExample components using a practical Acme support ticket workflow.
api: GET /tickets/{ticket_id}
---

Use `RequestExample` and `ResponseExample` to show real API usage alongside your endpoint docs. The components support multiple languages, response statuses, and inline explanations.

## Example: Retrieve a Support Ticket

This example documents a simple `GET /tickets/{ticket_id}` endpoint for the Acme Support API.

### Request

Use parameter fields to describe what the endpoint expects. The code sample lives in the right sidebar.

<ParamField path="ticket_id" type="string" required>
  Unique ticket identifier returned when the ticket was created.
</ParamField>

<RequestExample>
```bash cURL
curl -X GET https://api.acme.com/v1/tickets/tkt_9S8L2 \
  -H "Authorization: Bearer $ACME_TOKEN"
```

```python Python
import requests

response = requests.get(
    "https://api.acme.com/v1/tickets/tkt_9S8L2",
    headers={"Authorization": f"Bearer {ACME_TOKEN}"}
)

ticket = response.json()
print(ticket["id"])
```

```javascript JavaScript
const response = await fetch("https://api.acme.com/v1/tickets/tkt_9S8L2", {
  method: "GET",
  headers: {
    Authorization: `Bearer ${process.env.ACME_TOKEN}`,
  }
});

const ticket = await response.json();
console.log(ticket.id);
```

```go Go
package main

import (
  "fmt"
  "io"
  "net/http"
)

func main() {
  req, _ := http.NewRequest("GET", "https://api.acme.com/v1/tickets/tkt_9S8L2", nil)
  req.Header.Set("Authorization", "Bearer ACME_TOKEN")

  resp, _ := (&http.Client{}).Do(req)
  defer resp.Body.Close()

  body, _ := io.ReadAll(resp.Body)
  fmt.Println(string(body))
}
```

```ruby Ruby
require 'net/http'
require 'uri'
require 'json'

uri = URI("https://api.acme.com/v1/tickets/tkt_9S8L2")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Get.new(uri)
request["Authorization"] = "Bearer ACME_TOKEN"

response = http.request(request)
puts JSON.parse(response.body)
```

```csharp C#
using System.Net.Http;

var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer ACME_TOKEN");

var response = await client.GetAsync("https://api.acme.com/v1/tickets/tkt_9S8L2");
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
```

```java Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

HttpClient client = HttpClient.newHttpClient();

HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.acme.com/v1/tickets/tkt_9S8L2"))
    .header("Authorization", "Bearer ACME_TOKEN")
    .GET()
    .build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

```rust Rust
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
    let client = reqwest::Client::new();

    let response = client
        .get("https://api.acme.com/v1/tickets/tkt_9S8L2")
        .header("Authorization", "Bearer ACME_TOKEN")
        .send()
        .await?;

    let body = response.text().await?;
    println!("{}", body);

    Ok(())
}
```

```php PHP
<?php

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.acme.com/v1/tickets/tkt_9S8L2');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer ACME_TOKEN']);

$response = curl_exec($ch); curl_close($ch);

echo $response;
```
</RequestExample>

### Response

Use response fields to document the most important attributes returned by the API.

<ResponseField name="id" type="string" required>
  Unique ticket identifier.
</ResponseField>

<ResponseField name="status" type="string">
  Current ticket status (`open`, `pending`, or `resolved`).
</ResponseField>

<ResponseField name="created_at" type="string">
  ISO 8601 timestamp for when the ticket was created.
</ResponseField>

<ResponseExample>
```json 200: OK
{
  "id": "tkt_9S8L2",
  "customer_id": "cus_2X9W8",
  "subject": "Export stuck on step 3",
  "priority": "high",
  "status": "open",
  "created_at": "2026-02-04T16:12:00Z"
}
```

```json 404: Not found
{
  "code": "not_found",
  "message": "ticket_id does not exist"
}
```
</ResponseExample>

## Tips

- Include at least one success response and one error response.
- Use realistic identifiers and timestamps to make examples feel real.
- Keep payloads minimal so readers can scan quickly.

## Related Pages

<Columns cols={2}>
  <Card title="OpenAPI Example" icon="plug" href="/api-reference/openapi-example">
    See an auto-generated endpoint page
  </Card>
  <Card title="API Playground" icon="flask-vial" href="https://jamdesk.com/docs/api-reference/playground">
    Enable interactive API testing on your endpoint pages
  </Card>
</Columns>

<Columns cols={2}>
  <Card title="Examples Component" icon="code" href="https://jamdesk.com/docs/components/examples">
    Learn the component props and formatting rules
  </Card>
  <Card title="Fields Component" icon="list-check" href="https://jamdesk.com/docs/components/fields">
    Document request and response schemas
  </Card>
</Columns>
