> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ryzeapi.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Actualizar proxy

> Define o elimina el proxy individual de la instancia

**Auth:** `TokenAccount` o `TokenInstance` • **Rate-limit:** `Global` (100/min) • **Idempotente:** sí

## Descripción

Define un proxy HTTP, HTTPS o SOCKS5 específico para la instancia. La configuración solo surte efecto después de `/reconnect` o un nuevo `/connect`.

## Ejemplos

### SOCKS5 autenticado

Configura un proxy SOCKS5 en el puerto `1080` con usuario y contraseña. La contraseña se cifra at-rest con AES-256-GCM y nunca regresa en texto plano en la respuesta.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://ryzeapi.cloud/api/instance/proxy/my-instance" \
    -H "token: $Token_Instance" \
    -H "Content-Type: application/json" \
    -d '{
      "enabled": true,
      "host": "proxy.example.com",
      "port": "1080",
      "protocol": "socks5",
      "username": "user1",
      "password": "secret"
    }'
  ```

  ```javascript JavaScript theme={null}
  await fetch("https://ryzeapi.cloud/api/instance/proxy/my-instance", {
    method: "POST",
    headers: {
      "token":        process.env.Token_Instance,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      enabled:  true,
      host:     "proxy.example.com",
      port:     "1080",
      protocol: "socks5",
      username: "user1",
      password: "secret"
    })
  });
  ```

  ```python Python theme={null}
  import os, requests

  requests.post(
      "https://ryzeapi.cloud/api/instance/proxy/my-instance",
      headers={
          "token":        os.environ["Token_Instance"],
          "Content-Type": "application/json"
      },
      json={
          "enabled":  True,
          "host":     "proxy.example.com",
          "port":     "1080",
          "protocol": "socks5",
          "username": "user1",
          "password": "secret"
      }
  )
  ```

  ```go Go theme={null}
  package main

  import (
      "net/http"
      "os"
      "strings"
  )

  func main() {
      body := strings.NewReader(`{
          "enabled":  true,
          "host":     "proxy.example.com",
          "port":     "1080",
          "protocol": "socks5",
          "username": "user1",
          "password": "secret"
      }`)
      req, _ := http.NewRequest("POST", "https://ryzeapi.cloud/api/instance/proxy/my-instance", body)
      req.Header.Set("token", os.Getenv("Token_Instance"))
      req.Header.Set("Content-Type", "application/json")
      http.DefaultClient.Do(req)
  }
  ```
</CodeGroup>

### HTTP sin auth

Apunta a un proxy HTTP interno (`10.0.0.5:3128`) sin credenciales, escenario común en redes corporativas con auth-por-IP o proxy abierto.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://ryzeapi.cloud/api/instance/proxy/my-instance" \
    -H "token: $Token_Instance" \
    -H "Content-Type: application/json" \
    -d '{"enabled":true,"host":"10.0.0.5","port":"3128","protocol":"http"}'
  ```

  ```javascript JavaScript theme={null}
  await fetch("https://ryzeapi.cloud/api/instance/proxy/my-instance", {
    method: "POST",
    headers: {
      "token":        process.env.Token_Instance,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      enabled:  true,
      host:     "10.0.0.5",
      port:     "3128",
      protocol: "http"
    })
  });
  ```

  ```python Python theme={null}
  import os, requests

  requests.post(
      "https://ryzeapi.cloud/api/instance/proxy/my-instance",
      headers={
          "token":        os.environ["Token_Instance"],
          "Content-Type": "application/json"
      },
      json={
          "enabled":  True,
          "host":     "10.0.0.5",
          "port":     "3128",
          "protocol": "http"
      }
  )
  ```

  ```go Go theme={null}
  package main

  import (
      "net/http"
      "os"
      "strings"
  )

  func main() {
      body := strings.NewReader(`{"enabled":true,"host":"10.0.0.5","port":"3128","protocol":"http"}`)
      req, _ := http.NewRequest("POST", "https://ryzeapi.cloud/api/instance/proxy/my-instance", body)
      req.Header.Set("token", os.Getenv("Token_Instance"))
      req.Header.Set("Content-Type", "application/json")
      http.DefaultClient.Do(req)
  }
  ```
</CodeGroup>

### Deshabilitar

Envía solo `enabled: false` para eliminar el proxy individual de la instancia. Vuelve a usar el proxy global del deploy (si lo hay) o una conexión directa en la próxima reconexión.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://ryzeapi.cloud/api/instance/proxy/my-instance" \
    -H "token: $Token_Instance" \
    -H "Content-Type: application/json" \
    -d '{"enabled":false}'
  ```

  ```javascript JavaScript theme={null}
  await fetch("https://ryzeapi.cloud/api/instance/proxy/my-instance", {
    method: "POST",
    headers: {
      "token":        process.env.Token_Instance,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({ enabled: false })
  });
  ```

  ```python Python theme={null}
  import os, requests

  requests.post(
      "https://ryzeapi.cloud/api/instance/proxy/my-instance",
      headers={
          "token":        os.environ["Token_Instance"],
          "Content-Type": "application/json"
      },
      json={"enabled": False}
  )
  ```

  ```go Go theme={null}
  package main

  import (
      "net/http"
      "os"
      "strings"
  )

  func main() {
      body := strings.NewReader(`{"enabled":false}`)
      req, _ := http.NewRequest("POST", "https://ryzeapi.cloud/api/instance/proxy/my-instance", body)
      req.Header.Set("token", os.Getenv("Token_Instance"))
      req.Header.Set("Content-Type", "application/json")
      http.DefaultClient.Do(req)
  }
  ```
</CodeGroup>

## Respuesta exitosa

```json 200 OK theme={null}
{
  "success": true,
  "message": "Proxy configuration updated successfully",
  "proxy": {
    "enabled": true,
    "host": "proxy.example.com",
    "port": "1080",
    "protocol": "socks5",
    "username": "user1",
    "password": ""
  }
}
```

<Note>
  El `password` aparece como string vacío (`""`) en la respuesta, el servidor nunca devuelve la contraseña en texto plano.
</Note>

## Parámetros de ruta

<ParamField path="instance" type="string" required>
  Nombre de la instancia.
</ParamField>

## Cabeceras

<ParamField header="token" type="string" required>
  TokenAccount o TokenInstance.
</ParamField>

<ParamField header="Content-Type" type="string" required>
  `application/json`.
</ParamField>

## Cuerpo de la solicitud

<ParamField body="enabled" type="boolean" required>
  Habilita/deshabilita el proxy de la instancia.
</ParamField>

<ParamField body="host" type="string">
  IP o hostname. **Requerido** si `enabled=true`.
</ParamField>

<ParamField body="port" type="string">
  Puerto como string (`"1080"`, `"8080"`). **Requerido** si `enabled=true`.
</ParamField>

<ParamField body="protocol" type="string">
  `"http"`, `"https"` o `"socks5"`. **Requerido** si `enabled=true`.
</ParamField>

<ParamField body="username" type="string">
  Usuario (opcional).
</ParamField>

<ParamField body="password" type="string">
  Contraseña (opcional, cifrada at-rest).
</ParamField>

## Reglas

* `enabled=true` requiere `host`, `port` y `protocol`.
* `protocol` debe ser `http`, `https` o `socks5`.
* `username` / `password` son opcionales (proxy abierto o auth-por-IP).
* `enabled=false` hace que la instancia vuelva a usar el proxy default del deploy (si lo hay).
* La contraseña es **cifrada at-rest** (AES-256-GCM) y **redactada** en la respuesta.

## Notas

<Note>
  El proxy individual de la instancia tiene **prioridad** sobre el proxy global del deploy. Si `enabled=false`, la instancia usa el proxy global (si lo hay) o conexión directa.
</Note>

<Warning>
  Los cambios de proxy **no reconectan automáticamente**, llama a [`reconnect`](/es/api/instance/reconnect) para aplicar.
</Warning>

## Errores

| HTTP | `error.message`                                | Cuándo                         |
| :--: | ---------------------------------------------- | ------------------------------ |
|  400 | `Invalid request body`                         | JSON malformado.               |
|  400 | `Host is required when proxy is enabled`       | `enabled=true` sin `host`.     |
|  400 | `Port is required when proxy is enabled`       | `enabled=true` sin `port`.     |
|  400 | `Protocol is required when proxy is enabled`   | `enabled=true` sin `protocol`. |
|  400 | `Protocol must be one of: http, https, socks5` | `protocol` fuera del enum.     |
|  401 | `Invalid token`                                | Token faltante o inválido.     |
|  404 | `Instance not found`                           | Nombre no existe.              |
|  429 | `Rate limit exceeded. Try again later.`        | Más de 100 req/min.            |
|  500 | `Failed to update proxy configuration`         | Error de base de datos.        |

```json theme={null}
{
  "success": false,
  "error": {
    "message": "Protocol must be one of: http, https, socks5"
  }
}
```
