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

# Create Secret

Create an environment-scoped secret. The value is encrypted and is not returned
by the API.

<RequestExample>
  ```python Python theme={null}
  from retab import Retab

  client = Retab()

  secret = client.secrets.create_secret(name="RESEND_API_KEY", value="...")
  print(secret)
  ```

  ```typescript TypeScript theme={null}
  import { Retab } from "@retab/node";

  const client = new Retab({ apiKey: process.env.RETAB_API_KEY });

  const secret = await client.secrets.create_secret("RESEND_API_KEY", "...");
  console.log(secret);
  ```

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

  import (
  	"context"
  	"fmt"
  	"log"

  	retab "github.com/retab-dev/retab/clients/go"
  )

  func main() {
  	ctx := context.Background()

  	client, err := retab.NewClient("")
  	if err != nil {
  		log.Fatal(err)
  	}

  	secret, err := client.Secrets.Create(ctx, &retab.SecretsCreateParams{
  		Name:  "RESEND_API_KEY",
  		Value: "...",
  	})
  	if err != nil {
  		log.Fatal(err)
  	}
  	fmt.Println(*secret)
  }
  ```

  ```ruby Ruby theme={null}
  require 'retab'

  client = Retab::Client.new(api_key: ENV['RETAB_API_KEY'])

  secret = client.secrets.create_secret(name: 'RESEND_API_KEY', value: '...')
  puts secret
  ```

  ```rust Rust theme={null}
  use retab::Retab;
  use retab::models::CreateSecretRequest;
  use retab::resources::secrets::CreateSecretParams;

  #[tokio::main]
  async fn main() -> Result<(), Box<dyn std::error::Error>> {
      let client = Retab::new(std::env::var("RETAB_API_KEY")?);

      let secret = client
          .secrets()
          .create_secret(CreateSecretParams {
              body: CreateSecretRequest::new("RESEND_API_KEY", "..."),
          })
          .await?;
      println!("{:?}", secret);
      Ok(())
  }
  ```

  ```php PHP theme={null}
  <?php
  require 'vendor/autoload.php';

  use Retab\Client;

  $client = new Client(apiKey: getenv('RETAB_API_KEY'));

  $result = $client->secrets()->createSecret(
      name: 'RESEND_API_KEY',
      value: '...',
  );
  print_r($result);
  ```

  ```csharp C# theme={null}
  using Retab;
  using RetabClient = Retab.Retab;

  var apiKey = Environment.GetEnvironmentVariable("RETAB_API_KEY")!;
  var client = new RetabClient(apiKey);

  var result = await client.Secrets.CreateAsync(new SecretsCreateOptions
  {
      Name = "RESEND_API_KEY",
      Value = "...",
  });
  Console.WriteLine(result);
  ```

  ```java Java theme={null}
  import com.retab.RetabClient;

  public final class Example {
    public static void main(String[] args) throws Exception {
      RetabClient client = new RetabClient(System.getenv("RETAB_API_KEY"));

      var result = client.secrets().create("RESEND_API_KEY", "...");
      System.out.println(result);
    }
  }
  ```

  ```bash cURL theme={null}
  curl https://api.retab.com/v1/secrets \
    -H "Authorization: Bearer $RETAB_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"name":"RESEND_API_KEY","value":"..."}'
  ```
</RequestExample>


## OpenAPI

````yaml POST /v1/secrets
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://api.retab.com
security: []
paths:
  /v1/secrets:
    post:
      tags:
        - Secrets
      summary: Secret.Create
      operationId: create_secret
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSecretRequest'
        required: true
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SecretResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    CreateSecretRequest:
      properties:
        name:
          type: string
          pattern: ^[A-Za-z_][A-Za-z0-9_]*$
          title: Name
        value:
          type: string
          minLength: 1
          title: Value
      type: object
      required:
        - name
        - value
      title: CreateSecretRequest
    SecretResponse:
      properties:
        secret:
          $ref: '#/components/schemas/Secret'
      type: object
      required:
        - secret
      title: SecretResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
          default: []
      type: object
      title: HTTPValidationError
    Secret:
      properties:
        name:
          type: string
          pattern: ^[A-Za-z_][A-Za-z0-9_]*$
          title: Name
        created_at:
          type: string
          format: date-time
          title: Created At
          description: When the secret was first created.
        updated_at:
          type: string
          format: date-time
          title: Updated At
          description: When the secret value was last updated.
        created_by:
          anyOf:
            - type: string
            - type: 'null'
          title: Created By
        updated_by:
          anyOf:
            - type: string
            - type: 'null'
          title: Updated By
      type: object
      required:
        - created_at
        - name
        - updated_at
      title: Secret
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
          default: null
        ctx:
          type: object
          title: Context
          default: {}
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````