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

# POST Traces

> This endpoint lets you download traces for a project.

<Note>
  You will need a project level API key which can be generated on the same page
  by clicking `Generate API Key`.
</Note>

A complete list of supported parameters for the `POST traces` endpoint is provided below.

{" "}

<ParamField query="x-api-key" type="string" required>
  Your project level API key. This is a header parameter.
</ParamField>

<ParamField query="projectId" type="string" required>
  ID of your project. This can be found on the langtrace traces tab.
</ParamField>

<ParamField query="page" type="integer" required>
  The page number to retrieve. Starts from 1.
</ParamField>

<ParamField query="pageSize" type="integer" required>
  The number of traces to retrieve per page. Maximum value is 100.
</ParamField>

<Accordion title="200 (OK) Response Object Schema" defaultOpen="false">
  <ResponseField name="traces" type="object">
    <Expandable title="Traces object properties" defaultOpen="false">
      <ResponseField name="result" type="array">
        List of retrieved traces.
      </ResponseField>

      <ResponseField name="metadata" type="object">
        Metadata containing pagination information.

        <Expandable title="Metadata object properties" defaultOpen="false">
          <ResponseField name="page" type="integer">
            Page number of the current page.
          </ResponseField>

          <ResponseField name="page_size" type="integer">
            Number of traces per page.
          </ResponseField>

          <ResponseField name="total_pages" type="integer">
            Total number of pages. If the current page is less than the total
            pages, there are more traces to retrieve.
          </ResponseField>
        </Expandable>
      </ResponseField>
    </Expandable>
  </ResponseField>
</Accordion>

<Accordion title="Error Response Object Schema">
  <ResponseField name="error" type="object">
    <Expandable title="Error Object Properties" defaultOpen="false">
      <ResponseField name="message" type="string" required>
        Error message
      </ResponseField>
    </Expandable>
  </ResponseField>
</Accordion>

<RequestExample>
  ```bash cURL theme={null}
  curl -H "x-api-key: <LANGTRACE_API_KEY>" \
       -X POST \
       'https://app.langtrace.ai/api/traces' \
       --data-raw '{"page":1,"pageSize":1,"projectId":"<PROJECT_ID>"}'
  ```

  ```python Python theme={null}
  import requests

  url = 'https://app.langtrace.ai/api/traces'
  headers = {
  'x-api-key': '<LANGTRACE_API_KEY>',
  'Content-Type': 'application/json'
  }

  payload = {
  'page': 1,
  'pageSize': 1,
  'projectId': '<PROJECT_ID>',
  }

  response = requests.post(url, headers=headers, json=payload)
  print(response.text)

  ```

  ```javascript Javascript theme={null}
  const url = "https://app.langtrace.ai/api/traces";
  const headers = {
    "x-api-key": "<LANGTRACE_API_KEY>",
    "Content-Type": "application/json"
  };

  const payload = {
    page: 1,
    pageSize: 1,
    projectId: "<PROJECT_ID>",
  };

  fetch(url, {
    method: 'POST',
    headers: headers,
    body: JSON.stringify(payload)
  })
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

  ```
</RequestExample>

<ResponseExample>
  ```json Sample 200 (OK) Response theme={null}
  {"traces":{"result":[[{"name":"openai.chat.completions.create","trace_id":"0xebc4fe02c5291fdb1981228f49030cc4","span_id":"0x1c164d07b2c0fe71","trace_state":"[]","kind":0,"parent_id":"","start_time":"2024-08-08T21:25:30.275984Z","end_time":"2024-08-08T21:25:31.083383Z","attributes":"{\"langtrace.service.name\":\"OpenAI\",\"langtrace.service.type\":\"llm\",\"langtrace.service.version\":\"1.37.1\",\"langtrace.version\":\"2.2.17\",\"langtrace.sdk.name\":\"langtrace-python-sdk\",\"url.full\":\"https://api.openai.com/v1/\",\"url.path\":\"/chat/completions\",\"gen_ai.operation.name\":\"chat\",\"gen_ai.request.model\":\"gpt-4o-mini\",\"gen_ai.request.stream\":false,\"gen_ai.system\":\"openai\",\"gen_ai.response.model\":\"gpt-4o-mini-2024-07-18\",\"gen_ai.system_fingerprint\":\"fp_48196bc67a\",\"gen_ai.usage.input_tokens\":357,\"gen_ai.usage.output_tokens\":24,\"gen_ai.usage.total_tokens\":381}","status_code":"OK","events":"[{\"name\":\"gen_ai.content.prompt\",\"timestamp\":\"2024-08-08T21:25:30.276067Z\",\"attributes\":{\"gen_ai.prompt\":\"[{\\\"role\\\": \\\"system\\\", \\\"content\\\": \\\"You are a friendly customer support agent for Langtrace AI. You are helping a user with a question. Please provide a helpful response. Important: The response should be helpful and informative. DO NOT make up any information. Given some Context and a User Question, answer the question based on the provided context.\\\"}]\"}},{\"name\":\"gen_ai.content.completion\",\"timestamp\":\"2024-08-08T21:25:31.083279Z\",\"attributes\":{\"gen_ai.completion\":\"[{\\\"role\\\": \\\"assistant\\\", \\\"content\\\": \\\"Hello! I'm doing well, thank you! How can I assist you today with Langtrace or any of your questions?\\\"}]\"}}]","links":"[]","duration":807999}]],"metadata":{"page":1,"page_size":1,"total_pages":10}}}
  ```
</ResponseExample>
