Copy as Markdown[View as Markdown](/docs/sdk/functions/getMessageBySchemaPath.md)

***

# Function: getMessageBySchemaPath()

> **getMessageBySchemaPath**(`directory`): (`path`, `options`?) => `Promise`<`Message`>

Defined in: messages.ts:25

Returns a message from EventCatalog by a given schema path.

## Parameters[​](#parameters "Direct link to Parameters")

| Parameter   | Type     |
| ----------- | -------- |
| `directory` | `string` |

## Returns[​](#returns "Direct link to Returns")

`Function`

### Parameters[​](#parameters-1 "Direct link to Parameters")

| Parameter               | Type                           |
| ----------------------- | ------------------------------ |
| `path`                  | `string`                       |
| `options`?              | { `attachSchema`: `boolean`; } |
| `options.attachSchema`? | `boolean`                      |

### Returns[​](#returns-1 "Direct link to Returns")

`Promise`<`Message`>

## Example[​](#example "Direct link to Example")

```
import utils from '@eventcatalog/utils';

const { getMessageBySchemaPath } = utils('/path/to/eventcatalog');

// Get the message by the schema path
const message = await getMessageBySchemaPath('/path/to/eventcatalog/messages/InventoryAdjusted/schema.json');
const message = await getMessageBySchemaPath('/path/to/eventcatalog/messages/InventoryAdjusted/schema.avro');
```
