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

# Leased Subnet Management - Assign ASN (Create LOA)

> Attach an ASN to a leased IPv4 subnet by purchasing a LOA add-on, then verify LOA status for the service.

# Leased Subnet Management: Assign ASN (Create LOA)

This flow shows how to ***attach an ASN to a leased IPv4 subnet*** by purchasing a ***LOA (Letter of Authorization)*** add-on, and then how to ***check LOA status*** for the service.

Use this when a customer has an active leased subnet and wants:

* ROA / RPKI support
* route objects (RADB / ROUTE)
* inetnum automation (WHOIS)

> Conceptually: ***validate ASN → add LOA product to cart → checkout → LOA gets created for the service***.

***

## Prerequisites

You need:

* `{access_token}` (Auth flow)
* `{tenant_uuid}`
* `{asn}` (the ASN to assign to)
* `{subnet}` (notation string, e.g. `82.27.122.0/24`)
* `{company_name}` (used in LOA product fields)
* A billing `{address_uuid}` available for the tenant (from address list)
* A payment method `{payment_method_uuid}` available for the tenant (from payment method list)

If you plan to check LOA status afterwards, you also need:

* `{service_uuid}` of the leased subnet service (typically from “List Services” step in the lease flow)

***

## Flow overview

1. Validate ASN for the subnet
2. Add LOA/ASN item to cart
3. Complete checkout (standard cart steps)
4. List LOAs for the service to confirm status (Pending/Active)

***

## 1) Validate ASN for the subnet

> [Try it](/api-reference/common/asn-validate).

Before adding LOA to cart, validate that the ASN is eligible for the provided subnet(s).

```bash theme={null}
curl 'https://apigw.ipxo.com/billing/v1/{tenant_uuid}/asn/validate/{asn}' \
-X POST \
-H 'Authorization: Bearer {access_token}' \
-H 'Content-Type: application/json' \
--data-raw '{
    "subnets": ["{subnet}"]
  }'
```

### What this does

* Checks whether the ASN can be assigned to the subnet
* Returns validation info (AS name, country, flags like OFAC/spamhaus, and whether subnet is already added)

### What to look for

* `valid: true`
* `subnet.already_added: false` (if already added, you may not need to purchase again)

***

## 2) Add LOA / ASN item to cart

> [Try it](/api-reference/cart/add-item-to-shopping-cart)

This adds a LOA product (one-time) to the cart, configured with your ASN + subnet.

```bash theme={null}
curl 'https://apigw.ipxo.com/billing/v1/{tenant_uuid}/cart/items' \
-X POST \
-H 'Authorization: Bearer {access_token}' \
-H 'Content-Type: application/json' \
--data-raw '{
    "product_type": "loa",
    "billing_cycle": 0,
    "product_fields": {
      "max_length": 24,
      "company_name": "{company_name}",
      "asn": {asn},
      "info": "",
      "create_whois_inetnum": true,
      "whois_data_exposed": false,
      "subnets": ["{subnet}"]
    },
    "product_options": {
      "selection": {
        "roa": "yes",
        "radb": "yes",
        "route": "yes"
      }
    }
  }'
```

### What this does

* Adds a ***one-time purchasable LOA item*** to the cart
* Specifies optional automation:
  * `roa` (RPKI / ROA support)
  * `radb` + `route` (routing objects)
  * inetnum creation preferences

### Response

Often `HTTP 204 No Content` (same behavior as adding an IPv4 item). If you need confirmation, use [**List cart items**](lease-an-ipv4-subnet#4-list-cart-items).

***

## 3) Complete checkout (standard cart steps)

From here the flow becomes the “standard checkout block” you already have in [**Lease an IPv4 Subnet.**](lease-an-ipv4-subnet)

### 3.1 List cart (get `cart_uuid`)

> [Try it](/api-reference/cart/current-cart)

List the current cart

```bash theme={null}
curl 'https://apigw.ipxo.com/ecommerce/public/{tenant_uuid}/cart' \
-X GET \
-H 'Authorization: Bearer {access_token}'
```

***Save***:

* `{cart_uuid}`

***

### 3.2 Attach billing address to cart

> [Try it](/api-reference/cart/create-cart-address)

(Uses the address you already have from earlier **List company billing addresses** step.)

```bash theme={null}
curl 'https://apigw.ipxo.com/ecommerce/public/{tenant_uuid}/cart/{cart_uuid}/addresses/{address_uuid}' \
-X POST \
-H 'Authorization: Bearer {access_token}' \
-H 'Content-Type: application/json' \
--data-raw '{"type":"billing"}'
```

***

### 3.3 (Optional) Apply credits to cart

> [Try it](/api-reference/cart/apply-credits-to-cart)

```bash theme={null}
curl 'https://apigw.ipxo.com/ecommerce/public/{tenant_uuid}/cart/{cart_uuid}/credits/apply' \
-X POST \
-H 'Authorization: Bearer {access_token}' \
-H 'Content-Type: application/json' \
--data-raw '{"amount": 9}'
```

If credits are insufficient, you’ll still need a payment method assigned before checkout.

***

### 3.4 Checkout and create order

> [Try it](/api-reference/cart/checkout-cart)

```bash theme={null}
curl 'https://apigw.ipxo.com/ecommerce/public/{tenant_uuid}/cart/{cart_uuid}/checkout' \
-X POST \
-H 'Authorization: Bearer {access_token}' \
-H 'Content-Type: application/json' \
--data-raw '{}'
```

***Save***:

* `{order_uuid}` from response (optional, if you want order verification)

***

## 4) List LOAs for the service (Pending / Active)

> [Try it](/api-reference/market/list-of-billing-service-loa-documents)

After checkout, LOA creation may take a bit of processing time. This endpoint lets you confirm status.

```bash theme={null}
curl 'https://apigw.ipxo.com/billing/v1/{tenant_uuid}/market/ipv4/services/{service_uuid}/loa?statuses%5B0%5D=Active&statuses%5B1%5D=Pending' \
-X GET \
-H 'Authorization: Bearer {access_token}'
```

### What this returns

* LOAs associated with the leased subnet service

Typically you’ll see:

* `Pending` right after checkout
* `Active` once processed

### What to save (optional)

* `loa.uuid` if you later want LOA-specific operations (extend/renew/view details) when you add them.

***

## Variables used and introduced in this flow

| Variable                | Where it comes from             | Used for                    |
| ----------------------- | ------------------------------- | --------------------------- |
| `{asn}`                 | User input                      | Validate + add LOA          |
| `{subnet}`              | Leased subnet notation          | Validate + add LOA          |
| `{company_name}`        | Customer/company profile        | LOA details                 |
| `{cart_uuid}`           | List cart                       | Checkout steps              |
| `{address_uuid}`        | List company addresses          | Attach billing address      |
| `{payment_method_uuid}` | List payment methods            | Checkout                    |
| `{order_uuid}`          | Checkout response               | Optional order verification |
| `{service_uuid}`        | “List services” from lease flow | List LOAs                   |
