# Publish NWC Request

Publishes the NWC request event and returns the response

### Without Webhook

`POST` `https://api.getalby.com/nwc/nip47`

**Request Body**

| Name                                           | Type                                        | Description                                                                      |
| ---------------------------------------------- | ------------------------------------------- | -------------------------------------------------------------------------------- |
| relayUrl                                       | string                                      | If no relay is provided, it uses the default relay (wss\://relay.getalby.com/v1) |
| walletPubkey<mark style="color:red;">\*</mark> | string                                      | Pubkey of the NWC Wallet Provider                                                |
| event<mark style="color:red;">\*</mark>        | JSON object (see [example](#event-example)) | **Signed** request event                                                         |

#### Event Example

```json
{
  "id": "a16ycf4a01bcxx........xxxxx",
  "pubkey": "a16y69effexxxx........xxxxx",
  "created_at": 1700000021,
  "kind": 23194,
  "tags": [
    [
      "p",
      "a16y6sfa01bcxx........xxxxx"
    ]
  ],
  "content": "<encrypted content>",
  "sig": "<signature>"
}
// Source: https://pkg.go.dev/github.com/nbd-wtf/go-nostr@v0.30.0#Event
```

#### Response

{% tabs %}
{% tab title="200: OK" %}

```javascript
{
  "event": {
    "id": "a16ycf4a01bcxx........xxxxx",
    "pubkey": "a16y69effexxxx........xxxxx",
    "created_at": 1709033612,
    "kind": 23195,
    "tags": [
      [
        "p",
        "f490f5xxxxx........xxxxx"
      ],
      [
        "e",
        "a41aefxxxxx........xxxxx"
      ]
    ],
    "content": "<encrypted content>",
    "sig": "<signature>",
  },
  "state": "PUBLISHED"
}
```

{% endtab %}
{% endtabs %}

### With Webhook

`POST` `https://api.getalby.com/nwc/nip47/webhook`

**Request Body**

| Name                                           | Type                                        | Description                                                                           |
| ---------------------------------------------- | ------------------------------------------- | ------------------------------------------------------------------------------------- |
| relayUrl                                       | string                                      | If no relay is provided, it uses the default relay (wss\://relay.getalby.com/v1)      |
| webhookUrl<mark style="color:red;">\*</mark>   | string                                      | Webhook URL to publish the response event, returns the event directly if not provided |
| walletPubkey<mark style="color:red;">\*</mark> | string                                      | Pubkey of the NWC Wallet Provider                                                     |
| event<mark style="color:red;">\*</mark>        | JSON object (see [example](#event-example)) | **Signed** request event                                                              |

#### Response

{% tabs %}
{% tab title="200: OK" %}

```javascript
{
  "state": "WEBHOOK_RECEIVED"
}
```

{% endtab %}
{% endtabs %}

#### Response to webhook

{% tabs %}
{% tab title="200: OK" %}

```javascript
{
  "id": "a16ycf4a01bcxx........xxxxx",
  "pubkey": "a16y69effexxxx........xxxxx",
  "created_at": 1709033612,
  "kind": 23195,
  "tags": [
    [
      "p",
      "f490f5xxxxx........xxxxx"
    ],
    [
      "e",
      "a41aefxxxxx........xxxxx"
    ]
  ],
  "content": "<encrypted content>",
  "sig": "<signature>",
}
```

{% endtab %}
{% endtabs %}
