# .NET

### Requisitos previos

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

* [Obtener un access\_token de Afip SDK](https://app.afipsdk.com)

### 1. Instalación

Agregá la librería de Afip SDK en .NET.

{% tabs %}
{% tab title=".NET CLI" %}

```bash
dotnet add package Afip.Net
```

{% endtab %}

{% tab title="PMC" %}

```bash
NuGet\Install-Package Afip.Net
```

{% endtab %}

{% tab title="PackageReference" %}

```xml
<PackageReference Include="Afip.Net" />
```

{% endtab %}
{% endtabs %}

### 2. Crear una instancia de la clase Afip

Para usar los Web Services de ARCA se necesita un certificado digital, pero con Afip SDK podés empezar en modo desarrollo usando el CUIT 20-40937847-2 sin necesidad de uno.

Si preferís [usar tu propio certificado](#usar-tu-propio-certificado-opcional), al final te mostramos cómo.

{% tabs %}
{% tab title="Program.cs" %}

```csharp
using AfipSDK.Afip.Net;

var afip = new Afip(new AfipOptions
{
    CUIT = "20409378472",
    Production = false,
    AccessToken = "TU_ACCESS_TOKEN", // Obtenido de https://app.afipsdk.com
});
```

{% endtab %}
{% endtabs %}

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

Con la instancia creada ya podés realizar las 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 .NET:

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

***

### 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 lo agregamos a la instancia de la clase Afip.

{% tabs %}
{% tab title="Program.cs" %}
{% code fullWidth="true" %}

```csharp
using AfipSDK.Afip.Net;

var afip = new Afip(new AfipOptions
{
    CUIT = "20409378472",
    Production = false,
    AccessToken = "TU_ACCESS_TOKEN", // Obtenido de https://app.afipsdk.com
    Cert = "-----BEGIN CERTIFICATE-----MIIDRzC...",
    Key = "-----BEGIN RSA PRIVATE KEY-----MIIEowIBAAKCA..."
});
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions: 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/dotnet.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.
