When creating or updating a Buildkite pipeline via the REST API, wrap your pipeline YAML as an escaped string inside the JSON payload. If the API complains about the config, check the escaping before you doubt the YAML.

Context: From the official Buildkite REST API docs for pipelines. When you pass pipeline configuration through the REST API, the configuration must be escaped YAML inside a JSON string. Handing the API raw YAML, or YAML that is not properly escaped for the JSON string, is rejected. It is one of those places where the docs assume you already know the payload is a string containing YAML, not a nested object.