---
title: "Cambiar un texto dondequiera que aparezca"
description: "Sustituye un fragmento de texto del contenido o el código de un sitio en una sola entrada del historial e inicia la compilación."
canonical: "https://atelier201.com/docs/es/api/content/replace-text"
updated: "2026-11-06"
---

# Cambiar un texto dondequiera que aparezca

Requiere `sites:write`. No consume créditos. La ruta termina en `/text:replace`. Los cambios solo afectan al borrador. Los visitantes no verán nada hasta que [publiques](/docs/api/publishing/publish).

La forma más rápida de cambiar un texto visible si no sabes dónde está escrito. Envía `find` con el texto tal como aparece en la página y `replace` con el texto nuevo. Atelier201 busca en las fuentes del sitio dentro de `src/` (archivos de contenido y código de las páginas), sustituye el fragmento, crea una entrada en el historial e inicia la compilación. La respuesta incluye `build` con su identificador.

- **No se encuentra (`404`).** El texto no aparece exactamente así. Si un fragmento está dividido por marcado, como un enlace o una palabra en negrita en medio, no cuenta como un solo texto: envía un fragmento más corto.
- **Se encuentra varias veces (`409`).** Acota la búsqueda con `path` (un archivo o un patrón glob), envía un fragmento más largo o establece `all: true` para cambiar todas las apariciones, por ejemplo, un número de teléfono nuevo que se usa en varias páginas.
- **El contenido sigue siendo válido.** En un archivo de contenido JSON, el texto se busca y se escribe con el escape correspondiente a JSON. Después, el archivo se vuelve a analizar antes de guardar nada.

Si conoces la dirección de un campo, como `business:/tagline`, [Cambiar un campo](/docs/api/content/set-field) hace lo mismo y valida el resultado con el modelo de contenido.

```http
POST https://api.atelier201.com/v1/sites/{site_id}/text:replace
```

## Authorizations

- `Authorization` (bearer, in header, required)

## Path parameters

- `site_id` (`string`, required): El ID del sitio o su slug (la dirección antes de .atelier201.page).

## Body

`application/json`, required

- `find` (`string`, required, length: `1–2000 chars`): El texto que quieres cambiar, exactamente como aparece en la página o el archivo (incluidas mayúsculas, minúsculas y puntuación).
- `replace` (`string`, required, length: `≤ 5000 chars`): El texto nuevo. Si está vacío, se elimina el fragmento.
- `path` (`string`, length: `≤ 300 chars`): Solo en este archivo (o patrón glob, p. ej., src/pages/*.astro), si el texto aparece en varios.
- `all` (`boolean`): Cambiar todas las apariciones (un producto con otro nombre, un número de teléfono nuevo). Valor predeterminado: rechazar la operación si el texto aparece más de una vez.
- `summary` (`string`, length: `≤ 200 chars`): Una frase para el historial. Valor predeterminado: Change "<text>".

## Response

**200**: Cambiar un texto donde aparezca

- `data` (`object`, required)
- `data.replaced` (`integer`, required, range: `-9007199254740991–9007199254740991`): Número de apariciones modificadas.
- `data.files` (`object[]`, required)
- `data.files.path` (`string`, required)
- `data.files.occurrences` (`integer`, required, range: `-9007199254740991–9007199254740991`)
- `data.revision` (`string`, required, length: `40–40 chars`): Un ID de commit de Git (40 caracteres hexadecimales) del repositorio del sitio.
- `data.parent` (`string | null`, required)
- `data.changed` (`boolean`, required)
- `data.changes` (`object[]`, required)
- `data.changes.path` (`string`, required)
- `data.changes.action` (`string`, required)
- `data.build` (`object | null`, required): La compilación que inició este cambio (o a la que se incorporó): la vista previa la sigue. No hace falta llamar a build_site.
- `data.build.id` (`string`, required)
- `data.build.state` (`string`, required)
- `data.build.next_action` (`string`, required)
- `data.next_action` (`string`, required)
- `request_id` (`string`, required)

```json
{
  "data": {
    "replaced": 123,
    "files": [
      {
        "path": "<string>",
        "occurrences": 123
      }
    ],
    "revision": "<string>",
    "parent": "<string>",
    "changed": true,
    "changes": [
      {
        "path": "<string>",
        "action": "<string>"
      }
    ],
    "build": {
      "id": "<string>",
      "state": "<string>",
      "next_action": "<string>"
    },
    "next_action": "<string>"
  },
  "request_id": "<string>"
}
```

**400**: Códigos posibles: invalid_request, unknown_field, invalid_parameter, invalid_cursor

- `error` (`object`, required)
- `error.type` (`string`, required)
- `error.code` (`string`, required)
- `error.message` (`string`, required)
- `error.param` (`string`)
- `error.docs_url` (`string`, required)
- `error.action_url` (`string<uri>`)
- `error.details` (`Record<string, object>`)
- `request_id` (`string`, required)

```json
{
  "error": {
    "type": "<string>",
    "code": "<string>",
    "message": "<string>",
    "param": "<string>",
    "docs_url": "<string>",
    "action_url": "<string>",
    "details": {}
  },
  "request_id": "<string>"
}
```

**401**: Códigos posibles: authentication_required, invalid_api_key, api_key_expired, api_key_revoked

- `error` (`object`, required)
- `error.type` (`string`, required)
- `error.code` (`string`, required)
- `error.message` (`string`, required)
- `error.param` (`string`)
- `error.docs_url` (`string`, required)
- `error.action_url` (`string<uri>`)
- `error.details` (`Record<string, object>`)
- `request_id` (`string`, required)

```json
{
  "error": {
    "type": "<string>",
    "code": "<string>",
    "message": "<string>",
    "param": "<string>",
    "docs_url": "<string>",
    "action_url": "<string>",
    "details": {}
  },
  "request_id": "<string>"
}
```

**402**: Códigos posibles: insufficient_credits

- `error` (`object`, required)
- `error.type` (`string`, required)
- `error.code` (`string`, required)
- `error.message` (`string`, required)
- `error.param` (`string`)
- `error.docs_url` (`string`, required)
- `error.action_url` (`string<uri>`)
- `error.details` (`Record<string, object>`)
- `request_id` (`string`, required)

```json
{
  "error": {
    "type": "<string>",
    "code": "<string>",
    "message": "<string>",
    "param": "<string>",
    "docs_url": "<string>",
    "action_url": "<string>",
    "details": {}
  },
  "request_id": "<string>"
}
```

**403**: Códigos posibles: insufficient_scope, feature_not_available, admin_required

- `error` (`object`, required)
- `error.type` (`string`, required)
- `error.code` (`string`, required)
- `error.message` (`string`, required)
- `error.param` (`string`)
- `error.docs_url` (`string`, required)
- `error.action_url` (`string<uri>`)
- `error.details` (`Record<string, object>`)
- `request_id` (`string`, required)

```json
{
  "error": {
    "type": "<string>",
    "code": "<string>",
    "message": "<string>",
    "param": "<string>",
    "docs_url": "<string>",
    "action_url": "<string>",
    "details": {}
  },
  "request_id": "<string>"
}
```

**404**: Códigos posibles: resource_not_found

- `error` (`object`, required)
- `error.type` (`string`, required)
- `error.code` (`string`, required)
- `error.message` (`string`, required)
- `error.param` (`string`)
- `error.docs_url` (`string`, required)
- `error.action_url` (`string<uri>`)
- `error.details` (`Record<string, object>`)
- `request_id` (`string`, required)

```json
{
  "error": {
    "type": "<string>",
    "code": "<string>",
    "message": "<string>",
    "param": "<string>",
    "docs_url": "<string>",
    "action_url": "<string>",
    "details": {}
  },
  "request_id": "<string>"
}
```

**409**: Códigos posibles: conflict, result_not_ready, idempotency_key_reused

- `error` (`object`, required)
- `error.type` (`string`, required)
- `error.code` (`string`, required)
- `error.message` (`string`, required)
- `error.param` (`string`)
- `error.docs_url` (`string`, required)
- `error.action_url` (`string<uri>`)
- `error.details` (`Record<string, object>`)
- `request_id` (`string`, required)

```json
{
  "error": {
    "type": "<string>",
    "code": "<string>",
    "message": "<string>",
    "param": "<string>",
    "docs_url": "<string>",
    "action_url": "<string>",
    "details": {}
  },
  "request_id": "<string>"
}
```

**410**: Códigos posibles: result_expired

- `error` (`object`, required)
- `error.type` (`string`, required)
- `error.code` (`string`, required)
- `error.message` (`string`, required)
- `error.param` (`string`)
- `error.docs_url` (`string`, required)
- `error.action_url` (`string<uri>`)
- `error.details` (`Record<string, object>`)
- `request_id` (`string`, required)

```json
{
  "error": {
    "type": "<string>",
    "code": "<string>",
    "message": "<string>",
    "param": "<string>",
    "docs_url": "<string>",
    "action_url": "<string>",
    "details": {}
  },
  "request_id": "<string>"
}
```

**413**: Códigos posibles: request_too_large

- `error` (`object`, required)
- `error.type` (`string`, required)
- `error.code` (`string`, required)
- `error.message` (`string`, required)
- `error.param` (`string`)
- `error.docs_url` (`string`, required)
- `error.action_url` (`string<uri>`)
- `error.details` (`Record<string, object>`)
- `request_id` (`string`, required)

```json
{
  "error": {
    "type": "<string>",
    "code": "<string>",
    "message": "<string>",
    "param": "<string>",
    "docs_url": "<string>",
    "action_url": "<string>",
    "details": {}
  },
  "request_id": "<string>"
}
```

**422**: Códigos posibles: request_too_large_for_plan

- `error` (`object`, required)
- `error.type` (`string`, required)
- `error.code` (`string`, required)
- `error.message` (`string`, required)
- `error.param` (`string`)
- `error.docs_url` (`string`, required)
- `error.action_url` (`string<uri>`)
- `error.details` (`Record<string, object>`)
- `request_id` (`string`, required)

```json
{
  "error": {
    "type": "<string>",
    "code": "<string>",
    "message": "<string>",
    "param": "<string>",
    "docs_url": "<string>",
    "action_url": "<string>",
    "details": {}
  },
  "request_id": "<string>"
}
```

**429**: Códigos posibles: rate_limited

- `error` (`object`, required)
- `error.type` (`string`, required)
- `error.code` (`string`, required)
- `error.message` (`string`, required)
- `error.param` (`string`)
- `error.docs_url` (`string`, required)
- `error.action_url` (`string<uri>`)
- `error.details` (`Record<string, object>`)
- `request_id` (`string`, required)

```json
{
  "error": {
    "type": "<string>",
    "code": "<string>",
    "message": "<string>",
    "param": "<string>",
    "docs_url": "<string>",
    "action_url": "<string>",
    "details": {}
  },
  "request_id": "<string>"
}
```

**500**: Códigos posibles: internal_error

- `error` (`object`, required)
- `error.type` (`string`, required)
- `error.code` (`string`, required)
- `error.message` (`string`, required)
- `error.param` (`string`)
- `error.docs_url` (`string`, required)
- `error.action_url` (`string<uri>`)
- `error.details` (`Record<string, object>`)
- `request_id` (`string`, required)

```json
{
  "error": {
    "type": "<string>",
    "code": "<string>",
    "message": "<string>",
    "param": "<string>",
    "docs_url": "<string>",
    "action_url": "<string>",
    "details": {}
  },
  "request_id": "<string>"
}
```

**503**: Códigos posibles: service_unavailable

- `error` (`object`, required)
- `error.type` (`string`, required)
- `error.code` (`string`, required)
- `error.message` (`string`, required)
- `error.param` (`string`)
- `error.docs_url` (`string`, required)
- `error.action_url` (`string<uri>`)
- `error.details` (`Record<string, object>`)
- `request_id` (`string`, required)

```json
{
  "error": {
    "type": "<string>",
    "code": "<string>",
    "message": "<string>",
    "param": "<string>",
    "docs_url": "<string>",
    "action_url": "<string>",
    "details": {}
  },
  "request_id": "<string>"
}
```

**Example request**

```bash
curl --request POST \
  --url 'https://api.atelier201.com/v1/sites/<site_id>/text:replace' \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
  "find": "<string>",
  "replace": "<string>"
}'
```
