{"meta":{"title":"Puntos de conexión de API de REST para entornos previos a la recepción","intro":"Usa la API REST para crear, enumerar, actualizar y eliminar entornos para los enlaces previos a la recepción.","product":"REST API","breadcrumbs":[{"href":"/es/enterprise-server@3.21/rest","title":"REST API"},{"href":"/es/enterprise-server@3.21/rest/enterprise-admin","title":"Administración empresarial"},{"href":"/es/enterprise-server@3.21/rest/enterprise-admin/pre-receive-environments","title":"Entornos previos a la recepción"}],"documentType":"article"},"body":"# Puntos de conexión de API de REST para entornos previos a la recepción\n\nUsa la API REST para crear, enumerar, actualizar y eliminar entornos para los enlaces previos a la recepción.\n\n## Acerca de los entornos previos a la recepción\n\nEstos puntos de conexión solo están disponibles para los administradores de sitios [autenticados](/es/enterprise-server@3.21/rest/authentication/authenticating-to-the-rest-api). Los usuarios normales recibirán una respuesta `404`.\n\n> \\[!NOTE]\n> Estos puntos de conexión solo admiten la autenticación mediante personal access token (classic). Para más información, consulta [Administración de tokens de acceso personal](/es/enterprise-server@3.21/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic).\n\n### Atributos de objeto\n\n#### Ambiente de pre-recepción\n\n| Nombre                | Tipo      | Descripción                                                           |\n| --------------------- | --------- | --------------------------------------------------------------------- |\n| `name`                | `string`  | El nombre del entorno como se muestra en la interfaz de usuario (IU). |\n| `image_url`           | `string`  | La URL del tarball que se descargará y extraerá.                      |\n| `default_environment` | `boolean` | Tanto si se trata del entorno predeterminado que viene con GitHub.    |\n| `download`            | `object`  | El estado de descarga de este ambiente.                               |\n| `hooks_count`         | `integer` | La cantidad de ganchos de pre-recepción que utilizan este ambiente.   |\n\n#### Descarga del Ambiente de Pre-recepción\n\n| Nombre          | Tipo     | Descripción                                                                      |\n| --------------- | -------- | -------------------------------------------------------------------------------- |\n| `state`         | `string` | El estado de la descarga más reciente.                                           |\n| `downloaded_at` | `string` | La hora en la cual iniciaron la mayoría de las descrgas recientes.               |\n| `message`       | `string` | Cuando algo falla, este tendrá cualquier mensaje de error que se haya producido. |\n\nLos valores posibles de `state` son: `not_started`, `in_progress`, `success` y `failed`.\n\n> \\[!NOTE]\n> Most endpoints use `Authorization: Bearer <YOUR-TOKEN>` and `Accept: application/vnd.github+json` headers, plus `X-GitHub-Api-Version: 2026-03-10`. Curl examples below omit these standard headers for brevity.\n\n## List pre-receive environments\n\n```\nGET /admin/pre-receive-environments\n```\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`per_page`** (integer)\n  The number of results per page (max 100). For more information, see \"Using pagination in the REST API.\"\n  Default: `30`\n\n* **`page`** (integer)\n  The page number of the results to fetch. For more information, see \"Using pagination in the REST API.\"\n  Default: `1`\n\n* **`direction`** (string)\n  The direction to sort the results by.\n  Default: `desc`\n  Can be one of: `asc`, `desc`\n\n* **`sort`** (string)\n  Default: `created`\n  Can be one of: `created`, `updated`, `name`\n\n### HTTP response status codes\n\n* **200** - OK\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  http(s)://HOSTNAME/api/v3/admin/pre-receive-environments\n```\n\n**Response schema (Status: 200):**\n\nArray of objects:\n\n* `id`: integer, format: int64\n* `name`: string\n* `image_url`: string\n* `url`: string\n* `html_url`: string\n* `default_environment`: boolean\n* `created_at`: string\n* `hooks_count`: integer\n* `download`: object:\n  * `url`: string\n  * `state`: string\n  * `downloaded_at`: string or null\n  * `message`: string or null\n\n## Create a pre-receive environment\n\n```\nPOST /admin/pre-receive-environments\n```\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Body parameters\n\n* **`name`** (string) (required)\n  The new pre-receive environment's name.\n\n* **`image_url`** (string) (required)\n  URL from which to download a tarball of this environment.\n\n### HTTP response status codes\n\n* **201** - Created\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X POST \\\n  http(s)://HOSTNAME/api/v3/admin/pre-receive-environments \\\n  -d '{\n  \"name\": \"DevTools Hook Env\",\n  \"image_url\": \"https://my_file_server/path/to/devtools_env.tar.gz\"\n}'\n```\n\n**Response schema (Status: 201):**\n\n* `id`: integer, format: int64\n* `name`: string\n* `image_url`: string\n* `url`: string\n* `html_url`: string\n* `default_environment`: boolean\n* `created_at`: string\n* `hooks_count`: integer\n* `download`: object:\n  * `url`: string\n  * `state`: string\n  * `downloaded_at`: string or null\n  * `message`: string or null\n\n## Get a pre-receive environment\n\n```\nGET /admin/pre-receive-environments/{pre_receive_environment_id}\n```\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`pre_receive_environment_id`** (integer) (required)\n  The unique identifier of the pre-receive environment.\n\n### HTTP response status codes\n\n* **200** - OK\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  http(s)://HOSTNAME/api/v3/admin/pre-receive-environments/PRE_RECEIVE_ENVIRONMENT_ID\n```\n\n**Response schema (Status: 200):**\n\nSame response schema as [Create a pre-receive environment](#create-a-pre-receive-environment).\n\n## Update a pre-receive environment\n\n```\nPATCH /admin/pre-receive-environments/{pre_receive_environment_id}\n```\n\nYou cannot modify the default environment. If you attempt to modify the default environment, you will receive a 422 Unprocessable Entity response.\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`pre_receive_environment_id`** (integer) (required)\n  The unique identifier of the pre-receive environment.\n\n#### Body parameters\n\n* **`name`** (string)\n  This pre-receive environment's new name.\n\n* **`image_url`** (string)\n  URL from which to download a tarball of this environment.\n\n### HTTP response status codes\n\n* **200** - OK\n\n* **422** - Client Errors\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X PATCH \\\n  http(s)://HOSTNAME/api/v3/admin/pre-receive-environments/PRE_RECEIVE_ENVIRONMENT_ID \\\n  -d '{\n  \"name\": \"DevTools Hook Env\",\n  \"image_url\": \"https://my_file_server/path/to/devtools_env.tar.gz\"\n}'\n```\n\n**Response schema (Status: 200):**\n\nSame response schema as [Create a pre-receive environment](#create-a-pre-receive-environment).\n\n## Delete a pre-receive environment\n\n```\nDELETE /admin/pre-receive-environments/{pre_receive_environment_id}\n```\n\nIf you attempt to delete an environment that cannot be deleted, you will receive a 422 Unprocessable Entity response.\nThe possible error messages are:\n\nCannot modify or delete the default environment\nCannot delete environment that has hooks\nCannot delete environment when download is in progress\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`pre_receive_environment_id`** (integer) (required)\n  The unique identifier of the pre-receive environment.\n\n### HTTP response status codes\n\n* **204** - No Content\n\n* **422** - Client Errors\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X DELETE \\\n  http(s)://HOSTNAME/api/v3/admin/pre-receive-environments/PRE_RECEIVE_ENVIRONMENT_ID\n```\n\n**Response schema (Status: 204):**\n\n## Start a pre-receive environment download\n\n```\nPOST /admin/pre-receive-environments/{pre_receive_environment_id}/downloads\n```\n\nTriggers a new download of the environment tarball from the environment's image\\_url. When the download is finished, the newly downloaded tarball will overwrite the existing environment.\nIf a download cannot be triggered, you will receive a 422 Unprocessable Entity response.\nThe possible error messages are:\n\nCannot modify or delete the default environment\nCan not start a new download when a download is in progress\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`pre_receive_environment_id`** (integer) (required)\n  The unique identifier of the pre-receive environment.\n\n### HTTP response status codes\n\n* **202** - Accepted\n\n* **422** - Client Errors\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X POST \\\n  http(s)://HOSTNAME/api/v3/admin/pre-receive-environments/PRE_RECEIVE_ENVIRONMENT_ID/downloads\n```\n\n**Response schema (Status: 202):**\n\n* `url`: string\n* `state`: string\n* `downloaded_at`: string or null\n* `message`: string or null\n\n## Get the download status for a pre-receive environment\n\n```\nGET /admin/pre-receive-environments/{pre_receive_environment_id}/downloads/latest\n```\n\nIn addition to seeing the download status at the \"Get a pre-receive environment\" endpoint, there is also this separate endpoint for just the download status.\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`pre_receive_environment_id`** (integer) (required)\n  The unique identifier of the pre-receive environment.\n\n### HTTP response status codes\n\n* **200** - OK\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  http(s)://HOSTNAME/api/v3/admin/pre-receive-environments/PRE_RECEIVE_ENVIRONMENT_ID/downloads/latest\n```\n\n**Response schema (Status: 200):**\n\nSame response schema as [Start a pre-receive environment download](#start-a-pre-receive-environment-download)."}