# MessageApi

All URIs are relative to *http://localhost*

| Method | HTTP request | Description |
|------------- | ------------- | -------------|
| [**signMessage**](MessageApi.md#signmessageoperation) | **POST** /api/v1/message/sign | Sign a message |
| [**verifyMessage**](MessageApi.md#verifymessageoperation) | **POST** /api/v1/message/verify | Verify a signed message |



## signMessage

> SignedMessage signMessage(signMessageRequest)

Sign a message

Signs an arbitrary message with a BIP-340 Schnorr signature over a prefixed hash (&#x60;SHA256(\&quot;bark/message\&quot; || message)&#x60;) of the UTF-8 message bytes. The message is signed with the key of the given Ark address, which must be one of the wallet\&#39;s own addresses; addresses that do not belong to the wallet are rejected. The resulting signature can be checked with the &#x60;/message/verify&#x60; endpoint.

### Example

```ts
import {
  Configuration,
  MessageApi,
} from '@secondts/barkd';
import type { SignMessageOperationRequest } from '@secondts/barkd';

async function example() {
  console.log("🚀 Testing @secondts/barkd SDK...");
  const config = new Configuration({ 
    // Configure HTTP bearer authorization: bearer
    accessToken: "YOUR BEARER TOKEN",
  });
  const api = new MessageApi(config);

  const body = {
    // SignMessageRequest
    signMessageRequest: ...,
  } satisfies SignMessageOperationRequest;

  try {
    const data = await api.signMessage(body);
    console.log(data);
  } catch (error) {
    console.error(error);
  }
}

// Run the test
example().catch(console.error);
```

### Parameters


| Name | Type | Description  | Notes |
|------------- | ------------- | ------------- | -------------|
| **signMessageRequest** | [SignMessageRequest](SignMessageRequest.md) |  | |

### Return type

[**SignedMessage**](SignedMessage.md)

### Authorization

[bearer](../README.md#bearer)

### HTTP request headers

- **Content-Type**: `application/json`
- **Accept**: `application/json`


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | Returns the signature over the message |  -  |
| **400** | Invalid ark address or address not owned by this wallet |  -  |
| **500** | Internal server error |  -  |

[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)


## verifyMessage

> MessageVerification verifyMessage(verifyMessageRequest)

Verify a signed message

Verifies a BIP-340 Schnorr signature over a prefixed hash (&#x60;SHA256(\&quot;bark/message\&quot; || message)&#x60;) of the UTF-8 message bytes, as created by the &#x60;/message/sign&#x60; endpoint. The signature is checked against a public key (&#x60;pubkey&#x60;) or against the user public key of an Ark address (&#x60;address&#x60;); exactly one of the two must be set. Verification is stateless and works for signatures made by any wallet, not just this one.

### Example

```ts
import {
  Configuration,
  MessageApi,
} from '@secondts/barkd';
import type { VerifyMessageOperationRequest } from '@secondts/barkd';

async function example() {
  console.log("🚀 Testing @secondts/barkd SDK...");
  const config = new Configuration({ 
    // Configure HTTP bearer authorization: bearer
    accessToken: "YOUR BEARER TOKEN",
  });
  const api = new MessageApi(config);

  const body = {
    // VerifyMessageRequest
    verifyMessageRequest: ...,
  } satisfies VerifyMessageOperationRequest;

  try {
    const data = await api.verifyMessage(body);
    console.log(data);
  } catch (error) {
    console.error(error);
  }
}

// Run the test
example().catch(console.error);
```

### Parameters


| Name | Type | Description  | Notes |
|------------- | ------------- | ------------- | -------------|
| **verifyMessageRequest** | [VerifyMessageRequest](VerifyMessageRequest.md) |  | |

### Return type

[**MessageVerification**](MessageVerification.md)

### Authorization

[bearer](../README.md#bearer)

### HTTP request headers

- **Content-Type**: `application/json`
- **Accept**: `application/json`


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | Returns whether the signature is valid |  -  |
| **400** | Invalid signature, pubkey or address encoding, or not exactly one of pubkey and address set |  -  |
| **500** | Internal server error |  -  |

[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)

