# Automations and integrations

Automations and integrations

Agent documentation can be loaded using the following prompt :

```
curl https://p-link.io/ai-payment.md and connect to https://mcp.p-link.io/mcp
```

## x402 Protocol – Automated HTTP Payments

This page explains how the **x402 protocol** works and how it is used in **P-Link**.\
[Coinbase x402 ](https://github.com/coinbase/x402)makes it possible to introduce **native payments at the HTTP level**, allowing software agents (AI, scripts, services) to automatically pay for protected resources.

***

### What is the x402 protocol?

The **x402 protocol** is a modern extension of the HTTP status code **402 – Payment Required**.\
Its goal is to make payments **machine-readable, automated, and interoperable**, without requiring any human-facing payment interface (forms, buttons, checkout pages, etc.).

With x402:

* a server can signal that a payment is required using HTTP,
* a compatible client can understand the payment request,
* the payment can be executed automatically,
* the requested resource becomes accessible immediately after payment.

👉 x402 is especially well suited for **AI agents**, **paid APIs**, and **machine-to-machine payments**.

***

### Core principle

{% hint style="info" %}
Any P-Link complies to the x402 protocol, which means x402 client compatible agents can pay any P-Links

See : [How to create a P-Link](/receive-a-payment/receive-a-payment.md)
{% endhint %}

{% hint style="info" %}
P-Link MCP server exposes and endpoint that can be called in order to pay for any x402 protected resource, which means P-Link users can use agents to pay for any x402 protected resource using their P-Link account (on Solana only).
{% endhint %}

The protocol relies on a simple, standardized HTTP flow:

1. **Initial request**\
   The client requests a protected resource.
2. **402 – Payment Required response**\
   The server responds with:
   * HTTP status code `402`,
   * payment instructions (amount, currency, recipient, reference).
3. **Automatic payment**\
   A x402-compatible client:
   * parses the payment metadata,
   * executes the payment (e.g. blockchain, stablecoin),
   * stores a proof of payment.
4. **Retry with payment proof**\
   The client retries the original request, including the payment proof.
5. **Access granted**\
   The server verifies the payment and returns the requested resource.

***

### Why x402 in P-Link?

P-Link uses x402 to enable:

* automatic payment of HTTP resources,
* creation of **smart payment links**,
* payments initiated by **AI agents via MCP**,
* seamless integration with crypto wallets.

The goal is to make payments:

* **programmatic**,
* **frictionless**,
* **fully automatable**.

***

### Architecture in P-Link

#### x402 Server

The P-Link server can expose endpoints protected by x402.

When a resource requires payment:

* the server returns an HTTP 402 response,
* it includes all required payment metadata.

Typical protected resources include:

* premium APIs,
* downloadable content,
* paid actions or operations.

***

#### x402 Client

P-Link provides a client that can:

* detect HTTP 402 responses,
* interpret payment instructions,
* execute the payment automatically,
* retry the request with proof of payment.

This client can be used:

* in scripts,
* in MCP tools,
* by AI agents.

***

#### MCP (Model Context Protocol) Integration

All features in P-Link are exposed through **MCP**.

The MCP server is available at <https://mcp.p-link.io/mcp>

The MCP API exposes a JSON manifest describing all available tools for compatible clients (ChatGPT, Claude, n8n, etc.) : <https://mcp.p-link.io/.well-known/mcp/manifest.json>

Source code : <https://github.com/paracetamol951/P-Link-MCP>

This allows an AI to:

* pay a x402-protected URL,
* generate a payment link,
* send funds,
* inspect wallet data,

simply by invoking MCP tools.

***

### MCP Tools Available in P-Link

#### `pay_and_get_402_protected_url`

Pays a x402-protected URL and automatically retrieves the resource.

**Use case**\
An AI agent accesses a paid API without human intervention.

***

#### `request_payment_link`

Creates a customizable x402 payment link.

**Use case**\
Generate a link that can be paid by an external agent or service.

***

#### `send_money`

Sends funds to:

* a wallet address,
* an email address,
* or a phone number.

***

#### `get_wallet_info`

Returns wallet information:

* address,
* balance,
* network.

***

#### `get_wallet_history`

Retrieves the transaction history of the wallet.

***

### Example x402 flow

1. An AI agent attempts to access a premium API.
2. The server responds with HTTP 402 and payment instructions.
3. The agent calls `pay_and_get_402_protected_url`.
4. The payment is executed automatically.
5. The API response is returned.
6. The agent continues its task uninterrupted.

***

### Benefits of the x402 protocol

* Native HTTP payment signaling
* Fully automated payments
* Designed for AI agents
* No user interface required
* Ideal for micro-payments and paid APIs
* MCP-compatible

***

### Limitations and considerations

* The client must be **x402-compatible**
* A properly configured wallet is required
* Network or blockchain fees may apply

***

### Conclusion

The **x402 protocol** is a core building block of P-Link.\
It transforms a simple HTTP response into an **automated, machine-friendly payment mechanism**, enabling truly autonomous services and AI-driven workflows.

To go further:

* explore the examples in the P-Link repository,
* inspect the exposed MCP tools,
* test a full x402 flow with an AI agent.

***

P-Link also offers an **RSS** feed of payments received to an email address, phone number or wallet.

### RSS link format

`https://p-link.io/RSS/[email]`

💡 Example :\
`https://p-link.io/RSS/contact@net-assembly.com` → list of payments received by this email.

### Possible uses

* Integration with **Make**
* Automation with **IFTTT**
* Workflows **Zapier**
* Custom no-code applications


---

# 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.p-link.io/automations/automations-and-integrations.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.
