Batch Metadata Updates for Machines ๐Ÿš€

Machines already let you read all metadata or set/delete a single key, which works fine for small tweaks. But if you want to update several keys at once, doing it one-by-one can become pretty tedious.

The new PATCH /v1/apps/{app}/machines/{id}/metadata endpoint fixes that. You can now update or remove multiple metadata keys in a single request without touching anything else in the Machine config. Real values are set, and empty strings or null values remove keys. Simple, clean, and no chance of overwriting the whole map by accident.

A quick note on concurrency

PATCH makes multi-key updates atomic, but it doesnโ€™t guarantee request ordering. If a client fires off two PATCH requests back-to-back without waiting for responses, thereโ€™s no guarantee theyโ€™ll be applied in the order they were sent. We do plan to add lease support in the future, but for now this is a client-side limitation thatโ€™s worth calling out.


Example: setting multiple keys

curl -X PATCH "https://api.machines.dev/v1/apps/shaun-dev-test/machines/91850ee6a74383/metadata" \
  -H "Authorization: Bearer $FLY_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "metadata": {
      "foo": "barrrrr",
      "baz": "foo"
    }
}'
fly m status 91850ee6a74383 -d | jq .metadata
{
  "foo": "barrrrr",
  "baz": "foo"
}

Example: deleting multiple keys

curl -X PATCH "https://api.machines.dev/v1/apps/shaun-dev-test/machines/91850ee6a74383/metadata" \
  -H "Authorization: Bearer $FLY_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "metadata": {
      "cha": "cha",
      "foo": "",
      "baz": null
    }
}'
fly m status 91850ee6a74383 -d | jq .metadata
{
  "cha": "cha"
}

Feedback

If you have feedback or bump into anything unexpected, weโ€™d love to hear from you.

5 Likes