Title: Message::getJsonSchema
Published: May 20, 2026
Last modified: August 20, 2026

---

# Message::getJsonSchema()

## In this article

 * [Source](https://developer.wordpress.org/reference/classes/wordpress-aiclient-messages-dto-message/getjsonschema/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wordpress-aiclient-messages-dto-message/getjsonschema/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wordpress-aiclient-messages-dto-message/getjsonschema/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wordpress-aiclient-messages-dto-message/getjsonschema/?output_format=md#wp--skip-link--target)

{@inheritDoc}

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wordpress-aiclient-messages-dto-message/getjsonschema/?output_format=md#source)󠁿

    ```php
    public static function getJsonSchema(): array
    {
        return ['type' => 'object', 'properties' => [self::KEY_ROLE => ['type' => 'string', 'enum' => MessageRoleEnum::getValues(), 'description' => 'The role of the message sender.'], self::KEY_PARTS => ['type' => 'array', 'items' => \WordPress\AiClient\Messages\DTO\MessagePart::getJsonSchema(), 'minItems' => 1, 'description' => 'The parts that make up this message.']], 'required' => [self::KEY_ROLE, self::KEY_PARTS]];
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/php-ai-client/src/messages/dto/message.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/php-ai-client/src/Messages/DTO/Message.php#L115)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/php-ai-client/src/Messages/DTO/Message.php#L115-L118)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wordpress-aiclient-messages-dto-message/getjsonschema/?output_format=md#related)󠁿

| Uses | Description | 
| [MessagePart::getJsonSchema()](https://developer.wordpress.org/reference/classes/wordpress-aiclient-messages-dto-messagepart/getjsonschema/)`wp-includes/php-ai-client/src/Messages/DTO/MessagePart.php` |

{@inheritDoc}

  |

| Used by | Description | 
| [Candidate::getJsonSchema()](https://developer.wordpress.org/reference/classes/wordpress-aiclient-results-dto-candidate/getjsonschema/)`wp-includes/php-ai-client/src/Results/DTO/Candidate.php` |

{@inheritDoc}

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wordpress-aiclient-messages-dto-message/getjsonschema/?output_format=md#changelog)󠁿

| Version | Description | 
| [0.1.0](https://developer.wordpress.org/reference/since/0.1.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwordpress-aiclient-messages-dto-message%2Fgetjsonschema%2F)
before being able to contribute a note or feedback.