> ## Documentation Index
> Fetch the complete documentation index at: https://upstash-fix-issues-on-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Kafka Credential

> This endpoint creates a kafka credential.

## Request Parameters

<ParamField body="credential_name" type="string" required>
  The ID of the kafka topic
</ParamField>

<ParamField body="cluster_id" type="string" required>
  ID of the kafka cluster
</ParamField>

<ParamField body="topic" type="string" required>
  Name of the kafka topic the credential will be used for
</ParamField>

<ParamField body="permissions" type="string" required>
  Permission scope of the credential <br />
  **Options:** `ALL`, `PRODUCE` or `CONSUME`
</ParamField>

## Response Parameters

<ResponseField name="credential_id" type="string">
  ID of the created Kafka credential
</ResponseField>

<ResponseField name="credential_name" type="string">
  Name of the created Kafka credential
</ResponseField>

<ResponseField name="topic" type="string">
  Name of the topic of the created Kafka credential
</ResponseField>

<ResponseField name="permissions" type="string">
  Permission scope given to the kafka credential
</ResponseField>

<ResponseField name="cluster_id" type="string">
  ID of the kafka cluster
</ResponseField>

<ResponseField name="username" type="string">
  Username to be used for the kafka credential
</ResponseField>

<ResponseField name="creation_time" type="int">
  Creation time of the credential
</ResponseField>

<ResponseField name="password" type="string">
  Password to be used in authenticating to the cluster
</ResponseField>

<ResponseField name="state" type="string">
  State of the credential\ `active` or `deleted`
</ResponseField>

<RequestExample>
  ```shell curl
  curl -X POST \
    https://api.upstash.com/v2/kafka/credential \
    -u 'EMAIL:API_KEY' \
    -d '{"credential_name": "mycreds", "cluster_id":"1793bfa1-d96e-46de-99ed-8f91f083209d", "topic": "testtopic", "permissions": "ALL"}'
  ```

  ```python Python
  import requests

  data = '{"credential_name": "mycreds", "cluster_id":"1793bfa1-d96e-46de-99ed-8f91f083209d", "topic": "testtopic", "permissions": "ALL"}'

  response = requests.post('https://api.upstash.com/v2/credential', data=data, auth=('EMAIL', 'API_KEY'))
  response.content
  ```

  ```go Go
  client := &http.Client{}
  var data = strings.NewReader(`{
      "credential_name": "mycreds",
      "cluster_id":"1793bfa1-d96e-46de-99ed-8f91f083209d",
      "topic": "testopic",
      "permissions": "ALL"
  }`)
  req, err := http.NewRequest("POST", "https://api.upstash.com/v2/kafka/credential", data)
  if err != nil {
      log.Fatal(err)
  }
  req.SetBasicAuth("email", "api_key")
  resp, err := client.Do(req)
  if err != nil {
      log.Fatal(err)
  }
  bodyText, err := ioutil.ReadAll(resp.Body)
  if err != nil {
      log.Fatal(err)
  }
  fmt.Printf("%s\n", bodyText);
  ```
</RequestExample>

<ResponseExample>
  ```json 200 OK
  {
    "credential_id": "27172269-da05-471b-9e8e-8fe4195871bc",
    "credential_name": "mycreds",
    "topic": "testtopic",
    "permissions": "ALL",
    "cluster_id": "1793bfa1-d96e-46de-99ed-8f91f083209d",
    "cluster_slug":"easy-haddock-7753",
    "username":"ZWFzeS1oYWRkb2NrLTc3NTMkeeOs0FG4DZ3GxK99cArT0slAC37KLJgbe0fs7dA",
    "creation_time": 1655886853,
    "password": "xE1ypRHMq50jAhpbzu8qBb8jHNAxzezn6bkuRUvc2RZr7X1sznbhampm9p-feT61jnz6ewHJjUd5N6cQHhs84zCjQiP5somCY17FTQ7t6n0uPhWeyf-Fcw==",
    "state": "active"
  }
  ```
</ResponseExample>
