> For the complete documentation index, see [llms.txt](https://docs.afipsdk.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.afipsdk.com/integracion/ai-builders/replit.md).

# Replit

### Requisitos previos

Para poder seguir esta guía, primero necesitarás:

* [Obtener un access\_token de Afip SDK](https://app.afipsdk.com)
* Tener un Repl creado
* Definir el CUIT que vas a usar
* Elegir el Web Service ID, por ejemplo `wsfe` para factura electrónica

### 1. Configuración

En Replit, guardá las credenciales en **Secrets**. El backend puede leerlas desde `process.env`, pero el frontend no debe recibirlas ni imprimirlas.

{% tabs %}
{% tab title="Secrets" %}

```bash
AFIPSDK_ACCESS_TOKEN=TU_ACCESS_TOKEN
AFIPSDK_TAX_ID=20409378472
AFIPSDK_WSID=wsfe
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
No escribas `AFIPSDK_ACCESS_TOKEN` en archivos del repo ni lo imprimas en logs. Guardalo en Replit Secrets.
{% endhint %}

### 2. Crear la integración en Replit

Pedile a Replit que use el stack actual del proyecto. Si no hay backend, conviene pedir uno simple con Node.js y Express para que la integración quede fácil de revisar.

{% tabs %}
{% tab title="Prompt" %}

```
Integrá un web service de ARCA usando Afip SDK en este proyecto de Replit.

Usá el stack actual del proyecto. Si no hay backend, creá uno simple con Node.js y Express.

Necesito:
- Un secret llamado AFIPSDK_ACCESS_TOKEN.
- Una variable opcional AFIPSDK_TAX_ID para el CUIT por defecto.
- Una variable opcional AFIPSDK_WSID para el Web Service ID por defecto.
- Un endpoint backend /api/afipsdk/web-service.
- Una UI simple para ejecutar la consulta y ver el resultado JSON.

Endpoint backend:
- Leer AFIPSDK_ACCESS_TOKEN desde process.env.
- Recibir environment, tax_id, wsid y payload desde el frontend.
- Validar que existan AFIPSDK_ACCESS_TOKEN, tax_id y wsid.
- Hacer POST https://app.afipsdk.com/api/v1/afip/auth.
- Enviar Authorization: Bearer TU_ACCESS_TOKEN.
- Enviar body JSON con environment, tax_id y wsid.
- Usar token y sign de la respuesta para llamar al método del web service elegido según la documentación oficial.
- Devolver al frontend el resultado final.
- Devolver errores claros si falta el token, falta CUIT, falta wsid o Afip SDK responde error.

Reglas:
- No pongas el token en archivos del repo.
- No expongas secrets al frontend.
- No imprimas AFIPSDK_ACCESS_TOKEN en logs.
- No inventes campos de Afip SDK.
- Usá esta documentación:
  - https://docs.afipsdk.com/integracion/api
  - https://docs.afipsdk.com/siguientes-pasos/web-services/
  - https://docs.afipsdk.com/siguientes-pasos/web-services/otro-web-service
  - https://afipsdk.com/docs/api-reference/introduction/
```

{% endtab %}
{% endtabs %}

### 3. Llamar al método del Web Service que necesites

Con el endpoint creado ya podés realizar llamadas a los Web Services que necesites.

{% content-ref url="/pages/mVTz5YrKc8PCEeJKHt0W" %}
[Web services](/siguientes-pasos/web-services.md)
{% endcontent-ref %}

Si el Web Service que necesitás no se encuentra en la lista de la documentación, podés llamarlo siguiendo esta guía:

{% content-ref url="/pages/4zlCsTNGo99FZGfrhpZn" %}
[Otro web service](/siguientes-pasos/web-services/otro-web-service.md)
{% endcontent-ref %}

Podés usar la referencia de la API para obtener ejemplos de cómo usar los métodos de todos los web services de ARCA.

{% embed url="<https://afipsdk.com/docs/api-reference/introduction/>" %}

También podés usar las guías del blog de Afip SDK para Replit:

{% embed url="<https://afipsdk.com/blog/category/Replit/>" %}

***

### Usar tu propio certificado <sup><sub>(Opcional)<sub></sup>

Primero, obtenemos el certificado siguiendo esta guía.

{% embed url="<https://afipsdk.com/blog/como-obtener-certificado-para-web-services-arca/>" fullWidth="false" %}

Y luego agregá el certificado y la key como Secrets de Replit.

{% tabs %}
{% tab title="Secrets" %}

```bash
AFIPSDK_CERT=-----BEGIN CERTIFICATE-----...
AFIPSDK_KEY=-----BEGIN RSA PRIVATE KEY-----...
```

{% endtab %}

{% tab title="Prompt adicional" %}

```
Actualizá el endpoint /api/afipsdk/web-service para soportar certificado propio.

Reglas:
- Leer AFIPSDK_CERT y AFIPSDK_KEY desde process.env.
- No imprimir cert, key ni access token en logs.
- Al llamar a POST /api/v1/afip/auth, incluir cert y key en el body si existen.
- Mantener el frontend sin acceso a secrets.
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.afipsdk.com/integracion/ai-builders/replit.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
