---
title: "Export a codespace for the authenticated user"
method: POST
path: "/user/codespaces/{codespace_name}/exports"
tags: ["codespaces"]
---

# Export a codespace for the authenticated user

`POST /user/codespaces/{codespace_name}/exports`

Triggers an export of the specified codespace and returns a URL and ID where the status of the export can be monitored.

If changes cannot be pushed to the codespace's repository, they will be pushed to a new or previously-existing fork instead.

OAuth app tokens and personal access tokens (classic) need the `codespace` scope to use this endpoint.

## Path parameters

- `codespace_name` string, required

## Response `202`

Response

- CodespaceExportDetails — An export of a codespace. Also, latest export details for a codespace can be fetched with id = latest
  - `state` string, nullable — State of the latest export
  - `completed_at` string, date-time, nullable — Completion time of the last export operation
  - `branch` string, nullable — Name of the exported branch
  - `sha` string, nullable — Git commit SHA of the exported branch
  - `id` string — Id for the export details
  - `export_url` string — Url for fetching export details
  - `html_url` string, nullable — Web url for the exported branch

## Other responses

- `401` — Requires authentication
- `403` — Forbidden
- `404` — Resource not found
- `422` — Validation failed, or the endpoint has been spammed.
- `500` — Internal Error

---

[API](https://skmtc.net/github/apis/github-v3-rest-api-3.md) · [All operations](https://skmtc.net/github/apis/github-v3-rest-api-3/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/github/github-v3-rest-api-3/versions/dc0584ac4e13/schema)
