Docs Navigation

Api v2 Environment Variables

Stability: prototype

  1. List environment variables connected to a project
  2. List environment variables belonging to a secret
  3. Get an environment variable
  4. Create environment variable within a secret
  5. Update an environment variable
  6. Delete an environment variable

List environment variables connected to a project

GET /projects/{project_id}/env_vars
Response
HTTP status: 200

[
  {
    "id": "86e78b7e-2f9c-45a7-9939-ec2c9f6f64b5",
    "name": "API_TOKEN",
    "url": "https://api.semaphoreci.com/v2/env_vars/86e78b7e-2f9c-45a7-9939-ec2c9f6f64b5",
    "content": "8CgLAxXn",
    "shared": true,
    "encrypted": false,
    "created_at": "2017-06-10 16:59:51 +0200",
    "updated_at": "2017-06-10 16:59:51 +0200"
  }
]

List environment variables belonging to a secret

GET /secrets/{secret_id}/env_vars
Response
HTTP status: 200

[
  {
    "id": "86e78b7e-2f9c-45a7-9939-ec2c9f6f64b5",
    "name": "API_TOKEN",
    "url": "https://api.semaphoreci.com/v2/env_vars/86e78b7e-2f9c-45a7-9939-ec2c9f6f64b5",
    "content": "8CgLAxXn",
    "shared": true,
    "encrypted": false,
    "created_at": "2017-06-10 16:59:51 +0200",
    "updated_at": "2017-06-10 16:59:51 +0200"
  }
]

Get an environment variable

Displays the environment variable. Encrypted configuration files will have null as content.

GET /env_vars/{id}
Response
HTTP status: 200

{
  "id": "86e78b7e-2f9c-45a7-9939-ec2c9f6f64b5",
  "name": "API_TOKEN",
  "url": "https://api.semaphoreci.com/v2/env_vars/86e78b7e-2f9c-45a7-9939-ec2c9f6f64b5",
  "content": "8CgLAxXn",
  "shared": true,
  "encrypted": false,
  "created_at": "2017-06-10 16:59:51 +0200",
  "updated_at": "2017-06-10 16:59:51 +0200"
}

Create environment variable within a secret

Environment variables can be only created by users who can edit the secret.

POST /secrets/{secret_id}/env_vars
Request
Name Type Description
name string Required. Name of the environment variable.
content string Required. Content of the environment variable.
encrypted boolean Required.
Response
HTTP status: 200

{
  "id": "86e78b7e-2f9c-45a7-9939-ec2c9f6f64b5",
  "name": "API_TOKEN",
  "url": "https://api.semaphoreci.com/v2/env_vars/86e78b7e-2f9c-45a7-9939-ec2c9f6f64b5",
  "content": "8CgLAxXn",
  "shared": true,
  "encrypted": false,
  "created_at": "2017-06-10 16:59:51 +0200",
  "updated_at": "2017-06-10 16:59:51 +0200"
}

Update an environment variable

Environment variables can be only updated by users who has edit access on the project or the secret. Encrypted environment variables can't be edited.

PATCH /env_vars/{id}
Request
Name Type Description
name string Name of the environment variable.
content string Content of the environment variable.
Response
HTTP status: 200

{
  "id": "86e78b7e-2f9c-45a7-9939-ec2c9f6f64b5",
  "name": "API_TOKEN",
  "url": "https://api.semaphoreci.com/v2/env_vars/86e78b7e-2f9c-45a7-9939-ec2c9f6f64b5",
  "content": "8CgLAxXn",
  "shared": true,
  "encrypted": false,
  "created_at": "2017-06-10 16:59:51 +0200",
  "updated_at": "2017-06-10 16:59:51 +0200"
}

Delete an environment variable

Environment variables can be only deleted by users who has edit access on the project or the secret.

DELETE /env_vars/{id}
Response
HTTP status: 204

Semaphore Docs are open source — Edit on GitHub

Newsletter

Occasional lightweight product and blog updates. Unsubscribe at any time.

2009-2017 © Rendered Text. All rights reserved. Terms of Service, Privacy policy, Security.