# Sharing schema definition between two collections for schema validation (either tv4 or ajv)

**URL:** <https://community.postman.com/t/sharing-schema-definition-between-two-collections-for-schema-validation-either-tv4-or-ajv/38053>\
**Category:** Help Hub\
**Tags:** schema, ajv, tv4, validation, schemavalidation\
**Created:** [August 9, 2022, 7:35pm UTC](https://community.postman.com/t/sharing-schema-definition-between-two-collections-for-schema-validation-either-tv4-or-ajv/38053 "2022-08-09T19:35:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![andriykalashnykov](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/andriykalashnykov/32/12844_2.png) [@andriykalashnykov](https://community.postman.com/u/andriykalashnykov)\
**Post date:** [August 9, 2022, 7:35pm UTC](https://community.postman.com/t/sharing-schema-definition-between-two-collections-for-schema-validation-either-tv4-or-ajv/38053/1 "2022-08-09T19:35:49Z")

</div>

If a developer wants to use same _schema_ definition (same variable) in different collections what are advisable options?  
Today we just copy and paste the same schema definition variable in each collection (Pre-request Script tab) the downside of it is when schema needs to be changes it needs to be changed in multiple places. Is there a way to share it between collection calls maybe as a environment variable? (working example would be great)

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [August 10, 2022, 11:16am UTC](https://community.postman.com/t/sharing-schema-definition-between-two-collections-for-schema-validation-either-tv4-or-ajv/38053/2 "2022-08-10T11:16:13Z")

</div>

Could you not push this up to the Global variable scope so that every Collection in the Workspace would have access to it, when referenced?

It would also be a single place to make changes.

Something similar here I guess:

> <https://stackoverflow.com/questions/54464958/how-to-set-json-schema-as-a-global-variable-in-postman>

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [December 12, 2024, 12:54pm UTC](https://community.postman.com/t/sharing-schema-definition-between-two-collections-for-schema-validation-either-tv4-or-ajv/38053/3 "2024-12-12T12:54:14Z")

</div>

Closed on December 12, 2024, 12:54pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
