# Method: projects.schemas.validateMessage

- [HTTP request](https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.schemas/validateMessage#body.HTTP_TEMPLATE)
- [Path parameters](https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.schemas/validateMessage#body.PATH_PARAMETERS)
- [Request body](https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.schemas/validateMessage#body.request_body)
  - [JSON representation](https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.schemas/validateMessage#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.schemas/validateMessage#body.response_body)
- [Authorization scopes](https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.schemas/validateMessage#body.aspect)
- [Try it!](https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.schemas/validateMessage#try-it)

Validates a message against a schema.

### HTTP request

Choose a location:
<button value="global" default="">global</button>   
`POST https://pubsub.googleapis.com/v1/{parent}/schemas:validateMessage`

<br />

### Path parameters

| Parameters ||
|---|---|
| `parent` | `string` Required. The name of the project in which to validate schemas. Format is `projects/{project-id}`. |

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "message": string, "encoding": enum (`https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics#Encoding`), // Union field `schema_spec` can be only one of the following: "name": string, "schema": { object (`https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.schemas#Schema`) } // End of list of possible types for union field `schema_spec`. } ``` |

| Fields ||
|---|---|
| `message` | `string (https://developers.google.com/discovery/v1/type-format format)` Message to validate against the provided `schema_spec`. A base64-encoded string. |
| `encoding` | ``enum (`https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics#Encoding`)`` The encoding expected for messages |
| Union field `schema_spec`. `schema_spec` can be only one of the following: ||
| `name` | `string` Name of the schema against which to validate. Format is `projects/{project}/schemas/{schema}`. |
| `schema` | ``object (`https://docs.cloud.google.com/pubsub/docs/reference/rest/v1/projects.schemas#Schema`)`` Ad-hoc schema against which to validate |

### Response body

If successful, the response body is empty.

### Authorization scopes

Requires one of the following OAuth scopes:

- `https://www.googleapis.com/auth/pubsub`
- `https://www.googleapis.com/auth/cloud-platform`

For more information, see the [Authentication Overview](https://docs.cloud.google.com/docs/authentication#authorization-gcp).