# IRPCVaultExtensionMethods.RunExtensionMethod

Location: [gRPC API](https://developer.m-files.com/APIs/gRPC-API/index.md) > [Vault API](https://developer.m-files.com/APIs/gRPC-API/vault/index.md) > [Vault extension methods](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCVaultExtensionMethods/index.md)

HTML version: https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCVaultExtensionMethods/RunExtensionMethod/

Badges: `Vault API / standard` `write` `session` `returns metadata structure version`

Runs a vault extension method, either an event handler method or an application extension
method, with optional compression of the input and output.

- **Service:** [Vault extension methods](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCVaultExtensionMethods/index.md) `MFiles.IRPCVaultExtensionMethods`
- **gRPC method:** `/MFiles.IRPCVaultExtensionMethods/RunExtensionMethod`
- **HTTP (mf-http-grpc):** `POST /grpc/v1/run-extension-method`
- **Request:** [`RunExtensionMethodRequest`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCVaultExtensionMethods/RunExtensionMethod/index.md#request)
- **Response:** [`RunExtensionMethodResponse`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCVaultExtensionMethods/RunExtensionMethod/index.md#response)
- **Book and level:** Vault API, standard
- **Kind:** write
- **Session:** Required: the session ID from LogIn in the mfiles-session-id-bin metadata.
- **Idempotent:** no
- **Returns metadata structure version:** yes (in the mfiles-metadata-version-bin trailer)
- **Streaming:** none (unary)

<a id="remarks"></a>

## Remarks

- Requires a vault session; no special vault rights. The method's own code decides what the
  caller may do.
- With an all-zero (or empty) `application_id`, `method_name` names an event handler method and
  `extension` and `instance` are ignored. Otherwise the call goes to the extension object of the
  application.
- **Compression.** Set either `input` or `compressed_input`. When `compressed_input` is set, the
  server returns the output in `compressed_output` and leaves `output` empty. The compressed
  format is not plain zlib: it is a 4-byte little-endian length of the uncompressed data,
  followed by the zlib stream (RFC 1950) of the UTF-8 text **with a terminating zero byte**; the
  length includes that byte. Data in another format fails with "The parameter is incorrect.".
  The uncompressed size is limited to 100 MiB.

<a id="request"></a>

## Request: RunExtensionMethodRequest

Request data for running an extension method.

> Nested message fields are expanded to depth 3; follow a type link for deeper levels and for the type's own page.

| Field | Type | Description |
|---|---|---|
| `application_id` | `string` | The GUID of the vault application. All zeros or empty for an event handler method. |
| `extension` | `string` | The identifier of the application's extension object; empty for an event handler method. |
| `instance` | `string` | The identifier of the extension object instance; empty for an event handler method. |
| `method_name` | `string` | The name of the method. For an event handler method, the name of the VaultExtensionMethod event handler. |
| `input` | `string` | The input as text. Leave empty when `compressed_input` is used. |
| `compressed_input` | `bytes` | The compressed input: the 4-byte little-endian length of the UTF-8 text including a terminating zero byte, followed by the zlib stream of that text. Leave empty to use `input`. |

<a id="response"></a>

## Response: RunExtensionMethodResponse

The request data for RunExtensionMethod method.

> Nested message fields are expanded to depth 3; follow a type link for deeper levels and for the type's own page.

| Field | Type | Description |
|---|---|---|
| `output` | `string` | The output as text, when the input was not compressed. |
| `compressed_output` | `bytes` | When `compressed_input` was used, the output in the same compressed format: a 4-byte little-endian length, then the zlib stream of the UTF-8 text with a terminating zero byte. |
