> ## 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 Project API Key

> This endpoint enables creation of an api key for an existing project

<Note>You can find the `projectId` when you click on your project and copying the `Project ID` at the top of the `Traces` table. You will need a team level API key which can be generated by navigating to the Home page and clicking `Settings` -> `API Keys` -> `Generate API Key`.</Note>

<img className="block dark:hidden" src="https://mintcdn.com/langtraceai-2/hZpPXosaHdgAfpXF/images/api_key.png?fit=max&auto=format&n=hZpPXosaHdgAfpXF&q=85&s=4b1703d9d780b65f9211da61d8334aa2" alt="Hero Light" width="2624" height="1476" data-path="images/api_key.png" />

<img className="block dark:hidden" src="https://mintcdn.com/langtraceai-2/m7BVnnhK3Cx2yRxS/images/project_id.png?fit=max&auto=format&n=m7BVnnhK3Cx2yRxS&q=85&s=b1ae5c282affc67bbf436e7cd809031b" alt="Hero Light" width="3424" height="1926" data-path="images/project_id.png" />

A complete list of supported parameters for the `POST project api key` endpoint is provided below.

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

<Accordion title="200 (OK) Response Object Schema" defaultOpen="false">
  <ResponseField name="apiKey" type="string">
    Project api key
  </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 --request POST \
    --url https://app.langtrace.ai/api/api-key?project_id=cm0u2v1620001fmtvf2t8kd07 \
    --header 'Content-Type: application/json' \
    --header 'x-api-key: 6bd254a6615f48ea0da16823520db8efa4caa4186f62385fbd0f03324c7edcb5' \
  ```

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

  url = 'https://app.langtrace.ai/api/api-key?project_id=cm0u2v1620001fmtvf2t8kd07'
  headers = {
      'Content-Type': 'application/json',
      'x-api-key': '6bd254a6615f48ea0da16823520db8efa4caa4186f62385fbd0f03324c7edcb5'
  }

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

  ```javascript Javascript theme={null}
  const url = "https://app.langtrace.ai/api/api-key?project_id=cm0u2v1620001fmtvf2t8kd07";
  const headers = {
    "Content-Type": "application/json",
    "x-api-key": "6bd254a6615f48ea0da16823520db8efa4caa4186f62385fbd0f03324c7edcb5"
  };

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

  ```php PHP theme={null}
  <?php
  $curl = curl_init();

  curl_setopt_array($curl, [
      CURLOPT_URL => "https://app.langtrace.ai/api/api-key?project_id=cm0u2v1620001fmtvf2t8kd07",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_FOLLOWLOCATION => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_HTTPHEADER => [
          "Content-Type: application/json",
          "x-api-key: 6bd254a6615f48ea0da16823520db8efa4caa4186f62385fbd0f03324c7edcb5"
      ],
  ]);

  $response = curl_exec($curl);
  $err = curl_error($curl);

  curl_close($curl);

  if ($err) {
      echo "cURL Error #:" . $err;
  } else {
      echo $response;
  }
  ?>
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "encoding/json"
      "fmt"
      "net/http"
  )

  func main() {
      url := "https://app.langtrace.ai/api/api-key?project_id=cm0u2v1620001fmtvf2t8kd07"

      jsonData, err := json.Marshal(payload)
      if err != nil {
          fmt.Println("Error marshalling JSON:", err)
          return
      }

      req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
      if err != nil {
          fmt.Println("Error creating request:", err)
          return
      }
      req.Header.Set("Content-Type", "application/json")
      req.Header.Set("x-api-key", "6bd254a6615f48ea0da16823520db8efa4caa4186f62385fbd0f03324c7edcb5")

      client := &http.Client{}
      resp, err := client.Do(req)
      if err != nil {
          fmt.Println("Error making request:", err)
          return
      }
      defer resp.Body.Close()

      body, err := ioutil.ReadAll(resp.Body)
      if err != nil {
          fmt.Println("Error reading response body:", err)
          return
      }
      fmt.Println(string(body))
  }
  ```

  ```java Java theme={null}
  import java.net.URI;
  import java.net.http.HttpClient;
  import java.net.http.HttpRequest;
  import java.net.http.HttpResponse;
  import java.nio.file.Paths;
  import java.nio.file.Files;
  import java.io.IOException;

  public class Main {
      public static void main(String[] args) {
          HttpClient client = HttpClient.newHttpClient();
          
          HttpRequest request = HttpRequest.newBuilder()
              .uri(URI.create("https://app.langtrace.ai/api/api-key?project_id=cm0u2v1620001fmtvf2t8kd07"))
              .header("Content-Type", "application/json")
              .header("x-api-key", "6bd254a6615f48ea0da16823520db8efa4caa4186f62385fbd0f03324c7edcb5")
              .POST(HttpRequest.BodyPublishers.ofString(payload))
              .build();
          
          try {
              HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
              System.out.println(response.body());
          } catch (IOException | InterruptedException e) {
              e.printStackTrace();
          }
      }
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Sample 200 (OK) Response theme={null}
  {
      "apiKey" : "09dcd4714134db52615e79207e340f54b46311cc8b00cf501f4d86fc6906fa13"
  }
  ```

  ```json Sample Error Response theme={null}
  {
    "message": "Invalid api key unauthorized",
  }
  ```
</ResponseExample>
