Create environment variable

Creates a new environment variable. Restricted to admins only.
Required scopes: WORKSPACE, VARIABLE_ADD

Resource URL

POST /workspaces/:domain/variables

URL Parameters

NameTypeDescription
domain
Required
StringThe workspace domain.

POST Parameters

NameTypeDescription
key
Required
StringThe name of the variable.
value
Required
StringThe value of the variable.
descriptionStringThe optional description of the variable.
ssh_keyBooleanIf set to true the variable will be treated as an SSH key.
settableBooleanIf set to true the variable value can be set by Buddy actions.
encryptedBooleanIf set to true the variable value will be encrypted and hidden.
projectProjectThe project, to which the new environment variable will be added.
pipelinePipelineThe pipeline, to which the new environment variable will be added.
actionActionThe pipeline action, to which the new environment variable will be added.

Examples

Add a new workspace - scoped variable

Request

POST https://api.buddy.works/workspaces/buddy/variables

Example payload

JSON

{
"key": "id_myKey2",
"value": "-----BEGIN RSA PRIVATE KEY-----MIIEpAIBAAKCAQEAz/qH9/t6jCVuGPHcDDvnyqtasOlsjZOgF9dtRioNG93GrLPzDoi+SgUBzesoKXb1CGOW1wKAzLSADzuFMKwSydxCBVwziGZ33F+XsnHGKX3mpx8rRZV2UWNHRtJK3wmJHfEsIDHznPcbJT2I++cK36yGGpiNtzItfdvhExeFeXJVjp/BrZS2D4ixBu5VjqFe5XskIN6N//QCgfwxTwmnhoGBnB8xiWnDCHHUP/rf6Tr6FPneWt2zE5H53kqApT1boDN/VgaltptjW5zh6DnN6S9zhMBY4OkQoQQ1pCWrH56uryYaqTdslkoP4F1Hos9DkkCwCce8J/uFLE6PVY7Xk6JiQIDAQABAoIBAEOd5TTXetkzlh7gCzWjCFIY7d0SAaXdNCg9Fq/IYRzXT6sEwKYyt3g0WqbY1FkpaeojzXIH7tNDE/nabcWuNsC77oYgy3m8J3B/LQ6zbtPCirpPZ6vS8/UBmQFdRJ1YnwbvZ4aUnpZiu7+lODXf5BESDUpe75alEt7uzZn2K8cZQRb3O8cIpv4KIqxA4kpf+VkJ/1l8pLLx/cG85pxuLy6RlV8IlerOq7ZK85afdGPM9VKK+WNvL7803/Egt5Zs8p+Uc0W8ZXHhEzje4UreYE83AgU3EMSAJp69JnYQGGQsDHAC63GqUBSpWlI1gImZ9shD2rXrHkiiTnltcTWHx0CgYEA+UCU3rB+AoptMA/R9HxfJlgFacQPCnbSeziksTV0lyd44LiXJBBbchTKFg4sxBSuPcq0+rKnUxPcNNRbmw9Wvo+amqeyRvXDuXRXTxxmFpqDQehMW1A3Hav3aVfcarGcQAiZJAOQz1Hhma05Xy2HQsqHOqqVB7FktNcoIKccRgcCgYEA1ZvoHtkKG7ZAI+XJZmJUnsimWfH67prbAnlfBKGz/gDxA0REmTsAT92+T5jiXM6VyHj6G2GGVILZoG1L1YDecF/GLvhb3QmW8cwKnaX84XoI0oKYaNGnzmZIMcKQKZdFUZfbXBTT4I/xx1I+/aYRkp2WZBE5Emfg+RfZKkLT+8CgYBkyCMpo81fs58Qk1O3M4FkMxPxzVo4KWh8jKbUV3hplX9V1b83VDDQdfaB0qIibRA1r+MGSuJgFdHtOdSsRGHOnm6f0/y2ynq4Sv1ehIoWy6UVChuNtHKEsdrZImiCT4xxK8jYEgUEfwQsQil3fY46iG+DXiPiN20T3gdgpJ/EwKBgQCBon2LgxJ0YPWqE4FXpmNOfd0fBxDPj6FMbhYxPGV8yFt8LQkoqTr2PU+LBPCTfDhAktLOnTAlx8eFae804mGcdCY3P4Z/2lCRMGBV1OVAwEpyaDPGr41jglQhJUpek9g32h59z0ZwIU7Na0Nozm35cqVCk6CLnva013rhHwojdwKBgQCd1NBOpiE2/R7JsmK8crt0NH+Q9RFPKfnv4itvsuy9dRtDV04jl60jbzVC+EKD4M6jysijNF4TDTfXljmHjkx8oGW9PTZQ88TQm8maOO1mKuQAWAu3AeCIZXqdmiQQASD+p6+goJLgpKuKQJQ2LQJZgi1gvw+jBeTJPILXQgt1Q==-----END RSA PRIVATE KEY-----"",
"ssh_key": true,
"encrypted": true,
"description": "My Server Key"
}

Example Response

HTTP

Status: 201 Created
X-Rate-Limit-Limit: 1
X-Rate-Limit-Remaining: 999

JSON

{
"url": "https://api.buddy.works/workspaces/buddytest/variables/1",
"id": 1,
"key": "id_myKey",
"value": "secure!GvzY/ffwelVnYYXse/J8h1LUpRbdXcue5MPs23Gbe5qe53kCjv/OHKWJHQBREsyLfeN7eZacG3mGtKeO3Av5Y/azHqxFJ8gVFBTOV6KvkksjP9f1eVMc3enL6O5PYA4TXCotpcwaPrCPAxbkoJsluEwxRBS16CJBhtzP5oRkgp6vdv8pkqNDBYmfiQTZFi3BwOa1EZg9qWwte/uf+kHGbllDEnmf3i6qWf+sgokgBOMVA/1WD/GL8HnxDq1v5ydD5+LzI6A3NWqQKpIDm34rjpMlunC9pUi5sV1gRMYyyG34soozCKgtZmTjeAJSFbAim8Qdkoz9mSaevo5tbYrYdx+FihACt72222y8NaG2jIJfbgAieMoLipahkoCfngkHPkeiloVvSFgsLBPYB1jH1LquT/VR2YZH7sSlFei/6a4h21CKq4QCr//C4uKHKX37lv44z4vW1FJUzoHpSEOwLSRvS/3czpHFMy5K//K00Z7wFChkkUJxkI1AiUxsT4AtfTDAve3Mx51vaakldmvN37r+5mvIu6XVZu+cStPb7Y7669WfRNn26hIDXFOYyWXOvVcKR8PyThjsCF8zk3K/VON5UbDdTKANAbdTwgPSBW83cS9G9KyE74uERGWGTs2uP3LtcZJiWXkk8e8XYgjj5yKbir3YIvDkZunieeEnDrSvyVEU652AzmT8sLUNfP+xsqCRB1/YCMy1JV2se7kmPjnYXPuQWbIJMOC+44pyikNy2AvQWCq7Q7377vMlQisaqETy8L5aYUpPG9p0wrpx+5wG+rC9YZDenFllHg6FFvlfMcqdakqPcw7bUN8bXVCyMZ2sNkpIVOof0o17WJVDqk3W/yg+FbaEtLe81JQ1ORV6ED44ebJxUm841yqs9fXeTmcDYMSgtqzaJXLTHgmHXYHFYHX8+4eXO5VF6YFXmtUH+ORZlCi1+G1Hvc3hTMb0hI+yOLrcp/78GdStW5VTxJ3QkiohtgcmXC2xvlNGWmav3CFD8e2JEKJZXdXhOTlDLansGON7eUdA65RjjZ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p+ZkY17GAt6shc0QIxrW1XrxcOlFBkR2YWv7SBhC8oPMKBPa5IyInevlOPYQ==",
"ssh_key": true,
"encrypted": true,
"description": "My Server Key"
}

Add new project - scoped variable

Request

POST https://api.buddy.works/workspaces/buddy/variables

Example payload

JSON

{
"key": "my_var",
"value": "some value",
"project": {
"name": "myproject"
}
}

Example Response

HTTP

Status: 201 Created
X-Rate-Limit-Limit: 1
X-Rate-Limit-Remaining: 999

JSON

{
"url": "https://api.buddy.works/workspaces/buddytest/variables/1",
"id": 1,
"key": "my_var",
"value": "some value",
"ssh_key": false,
"encrypted": false
}

Add new pipeline-scoped variable

Request

POST https://api.buddy.works/workspaces/buddy/variables

Example payload

JSON

{
"key": "my_var",
"value": "some value",
"pipeline": {
"id": 1
}
}

Example Response

HTTP

Status: 201 Created
X-Rate-Limit-Limit: 1
X-Rate-Limit-Remaining: 999

JSON

{
"url": "https://api.buddy.works/workspaces/buddytest/variables/1",
"id": 1,
"key": "my_var",
"value": "some value",
"ssh_key": false,
"encrypted": false
}

Add new action - scoped variable

Request

POST https://api.buddy.works/workspaces/buddy/variables

Example payload

JSON

{
"key": "my_var",
"value": "some value",
"action": {
"id": 1
}
}

Example Response

HTTP

Status: 201 Created
X-Rate-Limit-Limit: 1
X-Rate-Limit-Remaining: 999

JSON

{
"url": "https://api.buddy.works/workspaces/buddytest/variables/1",
"id": 1,
"key": "my_var",
"value": "some value",
"ssh_key": false,
"encrypted": false
}