---
description: >-
  The Intents API is an JSON-RPC API facilitates intent publication, intent
  refinement, and data queries.
---

# Intents API

_Note: The request bodies in these docs always refer to the expected structure of the `params` field of a valid JSON-RPC payload. This is to avoid duplicating the same standard JSON-RPC information for every supported RPC method. Every HTTP request body calling the Intents JSON-RPC API should format HTTP body using the below top-level structure. The request body for each specific endpoint will solely denote the expected structure of the inner `params` field. The `method` field will also be specified in each specific endpoint documentation._

| Name      | Type      | Description                                |
| --------- | --------- | ------------------------------------------ |
| `jsonrpc` | string    | json-rpc version (always "2.0")            |
| `method`  | string    | The RPC method to call                     |
| `params`  | string\[] | The payload associated with the RPC method |
| `id`      | number    | The id of this RPC request                 |

#### A note on signatures

Some RPC methods require a signature as well. When a signature is required for a specific endpoint, it will be flagged as such. \
If the endpoint is a signature-only endpoint, then the JSON-RPC params&#x20;



### API Endpoints:

1. [Publish Intent](#publish-intent)
2. [Get Intent Status](#get-intent-status)
3. Request Refinement
4. Check Refinement Status

***

### Publish Intent

<mark style="color:green;">`POST`</mark> <mark style="color:green;"></mark><mark style="color:green;">\<medusa\_rpc\_url></mark>

Publishes an intent to Medusa.&#x20;

JSON-RPC Method: `"proposeIntent"`

_Signature required_

**Headers**

|              |                  |
| ------------ | ---------------- |
| content-type | application/json |

**Body (JSON-RPC Params)**

| Name        | Type   | Description                   |
| ----------- | ------ | ----------------------------- |
| `intent`    | Intent | The intent object to publish  |
| `signature` | string | The intent author's signature |

#### Intent Payload

The `intent` field of the request should look like so:

| Name        | Type   | Description                                                              |
| ----------- | ------ | ------------------------------------------------------------------------ |
| `author`    | string | Address of the intent author                                             |
| `ttl`       | number | The deadline to fill the intent                                          |
| `nonce`     | number | An author-specific nonce to ensure intent uniqueness.                    |
| `srcMToken` | string | Address of an mToken owned by the author that the author wishes to trade |
| `srcAmount` | number | The amount of `srcMToken` that the `author` wishes to sell               |
| Outcome     | JSON   | The `Outcome` struct                                                     |



**Example Request**

{% tabs %}
{% tab title="Propose Intent Payload" %}
```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "proposeIntent",
  "params": {
      "intent": {
        "author": 0xkhalanian,
        "ttl": 1000000000000,
        "nonce": 1,
        "srcMToken": 0xethUsdcMToken,
        "srcAmount": 100e18,
        "outcome": {
          "mTokens": [0xethDaiMToken],
          "mAmounts": [100e18],
          "outcomeAssetStructure": "AnySingle",
          "fillStructure": "Exactly"
        }
      },
      "signature": 0x...
   } 
}
```
{% endtab %}

{% tab title="Example Response" %}
```json
{ "response": {
    "transactionHash": "0x...", 
    "intentId": "0x..."
    }
}
```
{% endtab %}
{% endtabs %}

***

## Get Intent Status

<mark style="color:green;">`POST`</mark> `/<medusa rpc url>`

Get the status of a previously published intent.

JSON-RPC Method: `"getIntentStatus"`



**Headers**

| Name         | Value              |
| ------------ | ------------------ |
| Content-Type | `application/json` |

**Body (JSON-RPC Params)**

The `params` field of the JSON-RPC payload is a list of intent IDs.



**Example Request**

{% tabs %}
{% tab title="Example Request" %}
```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getIntentStatus",
  "params": [intentId]
}
```
{% endtab %}

{% tab title="Example Response" %}
```json
{
  "response": "Open"
}
```
{% endtab %}
{% endtabs %}
