[▲ Vercel Community](/) · [Categories](/categories) · [Latest](/latest) · [Top](/top) · [Events](/events) · [Live](/live)

[Help](/c/help/9)

# POST /v10/projects/{idOrName}/env?upsert=true creates duplicate keys for overlapping targets

0 views · 0 likes · 1 post


Ryan Hanson (Doppler) (@ryanhanson-4597) · 2026-10-16

**Description:** When using bulk upsert on the v10 environment variables endpoint, the API appears to match existing records by strict equality of the target array rather than checking for overlapping targets. If a variable exists for preview and an upsert request is sent for development and preview, a new variable record is created instead of updating the existing one, resulting in duplicate keys for the same environment.

**Reproduction Steps:**

```
# 1. Upsert a variable targeting development and preview when preview already exists
curl -s -X POST -H "Authorization: Bearer $VERCEL_TOKEN" -H "Content-Type: application/json" \
  "https://api.vercel.com/v10/projects/$PROJECT/env?upsert=true" \
  -d '[{"key":"REPRO_DUP","value":"both","type":"encrypted","visibility":"config","target":["development","preview"]}]'

# 2. Check variables - REPRO_DUP now exists twice for the preview target
curl -s -H "Authorization: Bearer $VERCEL_TOKEN" \
  "https://api.vercel.com/v8/projects/$PROJECT/env?decrypt=true" \
  | jq '[.envs[] | select(.key=="REPRO_DUP") | {id, target, type, value}]'

# 3. Upsert again with target ["development"]
curl -s -X POST -H "Authorization: Bearer $VERCEL_TOKEN" -H "Content-Type: application/json" \
  "https://api.vercel.com/v10/projects/$PROJECT/env?upsert=true" \
  -d '[{"key":"REPRO_DUP","value":"dev2","type":"encrypted","visibility":"config","target":["development"]}]'

# 4. Result leaves two separate records both targeting preview
curl -s -H "Authorization: Bearer $VERCEL_TOKEN" \
  "https://api.vercel.com/v8/projects/$PROJECT/env?decrypt=true" \
  | jq '[.envs[] | select(.key=="REPRO_DUP") | {id, target, type, value}]'
```


**Expected Behavior:** The upsert logic should check for environment target overlaps and either update existing entries or prevent duplicate keys from being assigned to the same target environment.