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

# Secrets

> SDK methods to create, list, retrieve, and manage secrets used by TrueFoundry deployments.

## Methods

<Accordion title="list">
  List secrets associated with a user filtered with optional parameters passed in the body.

  #### Parameters

  <ParamField body="limit" type="typing.Optional[int]">
    Number of items per page
  </ParamField>

  <ParamField body="offset" type="typing.Optional[int]">
    Number of items to skip
  </ParamField>

  <ParamField body="secret_fqns" type="typing.Optional[typing.Sequence[str]]">
    Array of FQNs
  </ParamField>

  <ParamField body="secret_group_id" type="typing.Optional[str]">
    Secret Group Id of the secret gourp.
  </ParamField>

  <ParamField body="with_value" type="typing.Optional[bool]">
    Whether to include the secret values in the response. Defaults to false.
  </ParamField>

  #### Returns

  <ResponseField name="SyncPager[Secret, ListSecretsResponse]" type="SyncPager[Secret, ListSecretsResponse]">
    [🔗 ListSecretsResponse](/docs/truefoundry_sdk/types#listsecretsresponse)

    Returns the secrets associated with a user filtered with optional parameters passed in the body.
  </ResponseField>

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry import TrueFoundry

  client = TrueFoundry(
      api_key="YOUR_API_KEY",
      base_url="https://yourhost.com/path/to/api",
  )

  client.secrets.list(
      limit=10,
      offset=10,
      secret_fqns="value",
      secret_group_id="value",
      with_value="value",
  )

  # Iterate through results
  for item in response:
      print(item.name)

  # Or paginate page by page
  for page in response.iter_pages():
      for item in page:
          print(item.name)
  ```
</Accordion>

<Accordion title="get">
  Get Secret associated with provided id. The secret value is not returned if the control plane has `DISABLE_SECRET_VALUE_VIEW` set

  #### Parameters

  <ParamField body="id" type="str" required>
    Secret Id of the secret.
  </ParamField>

  #### Returns

  <ResponseField name="GetSecretResponse" type="GetSecretResponse">
    [🔗 GetSecretResponse](/docs/truefoundry_sdk/types#getsecretresponse)

    Returns the Secret associated with provided id
  </ResponseField>

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry import TrueFoundry

  client = TrueFoundry(
      api_key="YOUR_API_KEY",
      base_url="https://yourhost.com/path/to/api",
  )

  client.secrets.get(
      id="id_value",
  )
  ```
</Accordion>

<Accordion title="delete">
  Deletes a secret and its versions along with its values.

  #### Parameters

  <ParamField body="id" type="str" required>
    Secret Id of the secret.
  </ParamField>

  <ParamField body="force_delete" type="typing.Optional[bool]">
    Whether to force delete the secret.
  </ParamField>

  #### Returns

  <ResponseField name="float" type="float">
    Deletes a secret and its versions along with its values and returns the count of the deleted secrets.
  </ResponseField>

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry import TrueFoundry

  client = TrueFoundry(
      api_key="YOUR_API_KEY",
      base_url="https://yourhost.com/path/to/api",
  )

  client.secrets.delete(
      id="id_value",
      force_delete="value",
  )
  ```
</Accordion>
