Env_var: Duplicate resource on another branch

,

What I try to accomplish:

I want to create environment variables with different values per branch with the API.
This is possible within the portal:

The problem

I get a 409 conflict error when I try to create a new variable with a name which exists for another branch.

{
    "@type": "error",
    "error_type": "duplicate_resource",
    "error_message": "resource already exists"
}

The query I execute:

# The first query, non existing variable, this is fine and executes with a 201 Response
curl --location --request POST 'https://api.travis-ci.com/repo/xxxxxx/env_vars' \
--header 'Authorization: token xxxxxx' \
--header 'Travis-API-Version: 3' \
--header 'Content-Type: application/json' \
--data-raw '{
    "env_var.name": "Test_var",
    "env_var.value": "testvalue",
    "env_var.public": false,
    "env_var.branch": "development"
}'

# The second query, fails with a 409.
curl --location --request POST 'https://api.travis-ci.com/repo/xxxxxx/env_vars' \
--header 'Authorization: token xxxxxx' \
--header 'Travis-API-Version: 3' \
--header 'Content-Type: application/json' \
--data-raw '{
    "env_var.name": "Test_var",
    "env_var.value": "testvalue2",
    "env_var.public": false,
    "env_var.branch": "test"
}'

I tried with patching the given env var, but this results in overwriting the env_var from the other branch.

Is this a bug? Or am I missing something?

Additionally, the type of the branch property is missing in the env_var and env_vars documentation

Imprint