How do I upload source maps automatically on every deploy?

Add one step to your deploy job, after the build and before the files are published. Inject debug IDs, POST each .map file with an upload token kept as a CI secret, delete the maps from the output, then deploy those same files. A Project holds at most 200 maps, and maps stored by debug ID cannot be deleted.

Last updated 26 November 2026. By Paul Badarau.

A fictional ticketing site deploys from its main branch about five times a week. Each build has three bundles. Its deploy job builds, uploads the maps, removes them, and publishes the folder, so every error from a new build opens with the original function names and nobody has to remember a manual step.

The job, in order:

  1. Store two secrets in your CI. PD_UPLOAD_TOKEN is an upload token from Setup in Monitoring, created by an Owner or Administrator and shown once. PD_UPLOAD_URL is the address on your DSN's host, such as https://DSN_HOST/api/4821/artifacts/, where 4821 is the number at the end of your DSN.
  2. Build with your usual command, such as npm run build, with hidden source maps turned on so the bundles do not point browsers at the maps.
  3. Inject debug IDs into the bundles and maps: sentry-cli sourcemaps inject dist.
  4. Upload each map, and stop at the first refusal: for map in $(find dist -name '*.map'); do curl --fail -sS -X POST "$PD_UPLOAD_URL" -H "Authorization: Bearer $PD_UPLOAD_TOKEN" -H "Content-Type: application/json" --data-binary "@$map" || exit 1; done
  5. Remove the maps from the output: find dist -name '*.map' -delete.
  6. Deploy dist as usual.

Steps 3 to 6 must act on the same files. A deploy step that runs the build again gives the bundles new debug IDs, and the uploaded maps match nothing.

Rerunning a failed job is safe. Identical maps are stored once, reported as unchanged, and not counted toward the Project's 60 uploads a minute. Each request counts as one upload, so a zip of up to 32 maps, sent as application/zip, also keeps a large build under that limit.

Decide what a refused upload should do. With || exit 1, a refusal stops the deploy, which keeps every release readable but can hold back a fix. Without it, the release ships and its errors stay minified until you upload the maps by hand. Late maps still apply to stored events, so on a small site the second choice loses little if you upload within 7 days.

A Project holds at most 200 maps, and a map stored by debug ID can be neither replaced nor deleted. The ticketing site adds 15 maps a week, so it fills the Project in about 13 weeks. After that, every upload is refused with 413 map_capacity and new builds stay minified. Upload only the maps of bundles that contain your own code, and skip vendor chunks, to make the room last.

The product page for this is Monitoring.

Start your 14-day free trial