# How to save schema to environment and reuse it after

**URL:** <https://community.postman.com/t/how-to-save-schema-to-environment-and-reuse-it-after/1359>\
**Category:** Help Hub\
**Tags:** environments, schema\
**Created:** [April 3, 2018, 11:24am UTC](https://community.postman.com/t/how-to-save-schema-to-environment-and-reuse-it-after/1359 "2018-04-03T11:24:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alzarka](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@alzarka](https://community.postman.com/u/alzarka)\
**Post date:** [April 3, 2018, 11:24am UTC](https://community.postman.com/t/how-to-save-schema-to-environment-and-reuse-it-after/1359/1 "2018-04-03T11:24:03Z")

</div>

Lets say I have picture schema, which I will need to reuse it in different requests. How can I save this scheme in an environment and then fetch it from environment and reuse it?

My picture scheme:

var schemaPicture = {  
“type”: “object”,  
“required” : [“small”, “medium”, “large”],  
“properties”: {  
“small”: { “type”: “string” },  
“medium”: { “type”: “string” },  
“large”: { “type”: “string” }  
},  
“additionalProperties”: false  
};

In this schema I will need to add the picture scheme:

const commentSchema = {  
“type”: “object”,  
“required”: [“success”],  
“properties”: {  
“success”: { “type”: “boolean” },  
“count”: { “type”: “integer” },  
“data”: {  
“type”: “object”,  
“required”: [“id”, “value”, “created”],  
“properties”: {  
“type”: “object”,  
“id”: { “type”: “integer” },  
“value”: { “type”: “string” },  
“created”: {  
“type”: “object”,  
“required” : [“time”, “user”],  
“properties”: {  
“time”: { “type”: “string” },  
“user”: {  
“type”: “object”,  
“required” : [“name”, “username”],  
“properties”: {  
“id”: { “type”: “integer” },  
“name”: { “type”: “string” },  
“surname”: { “type”: “string” },  
“username”: { “type”: “string” },  
“picture”: schemaPicture !!!\<\<\<\< I need to put the schema here  
},  
}  
},  
}  
},  
},  
}  
};

---

<div class="post-metadata">

**Author:** ![kunagpal](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/kunagpal/32/9_2.png) [@kunagpal](https://community.postman.com/u/kunagpal)\
**Post date:** [April 6, 2018, 9:24am UTC](https://community.postman.com/t/how-to-save-schema-to-environment-and-reuse-it-after/1359/2 "2018-04-06T09:24:18Z")

</div>

Hey @alzarka, this looks quite similar to [How to save schema to environment and reuse it after](https://community.postman.com/t/how-to-save-schema-to-environment-and-reuse-it-after/1359). You can reuse schema definitions across requests as follows:

1. Save `pictureSchema` into an environment variable as follows:

```auto
pm.environment.set('picture_schema', JSON.stringify(schemaPicture));

```

1. In the script where `commentSchema` is defined, refer `pictureSchema` as follows:

```auto
const commentSchema = {
   .
   .
   .
   "picture": JSON.parse(pm.environment.get('picture_schema'))
   .
   .
   .
}

```

In this manner, you can include the common reference wherever needed.

---

<div class="post-metadata">

**Author:** ![alzarka](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@alzarka](https://community.postman.com/u/alzarka)\
**Post date:** [April 6, 2018, 10:24am UTC](https://community.postman.com/t/how-to-save-schema-to-environment-and-reuse-it-after/1359/3 "2018-04-06T10:24:35Z")

</div>

> [@kunagpal](#):
>
> “picture”: JSON.parse(pm.environment.get(‘picture\_schema’))

THANK YOU, THIS HELPS ME OUT A LOT
