# How can I import a Schema in graphql file using API

**URL:** <https://discuss.dgraph.io/t/how-can-i-import-a-schema-in-graphql-file-using-api/15403>\
**Category:** Dgraph Cloud\
**Created:** [August 27, 2021, 10:23am UTC](https://discuss.dgraph.io/t/how-can-i-import-a-schema-in-graphql-file-using-api/15403 "2021-08-27T10:23:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![smolto](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/smolto/32/8776_2.png) [@smolto](https://discuss.dgraph.io/u/smolto)\
**Post date:** [August 27, 2021, 10:23am UTC](https://discuss.dgraph.io/t/how-can-i-import-a-schema-in-graphql-file-using-api/15403/1 "2021-08-27T10:23:10Z")

</div>

Hi, I am trying to configure my schema without using the Dgraph Cloud UI. I’ve been looking for this solution in the documentation, but I can’t find it and I’m a bit stuck with this problem.

The thing is that I’ve found the solution but only when is Dgraph is self hosted. In this [article](https://dgraph.io/docs/graphql/todo-app-tutorial/todo-schema-design/), It sais that you can create a graphql file and set your schema inside, and then using this request ` curl -X POST localhost:8080/admin/schema --data-binary '@schema.graphql'` you can set it by http protocol but, when you are using cloud that endpoint does not exist. They gave you the following solution but, is there any way of combining this two? I do not have much experience using Dgraph and curl.

```auto
#!/usr/bin/env bash

DEPLOYMENT_URL="polished-violet.us-east-1.aws.cloud.dgraph.io"
DEPLOYMENT_JWT="<deployment-jwt>"

curl "https://${DEPLOYMENT_URL}/admin" \
  -H "Content-Type: application/json" \
  -H "X-Auth-Token: ${DEPLOYMENT_JWT}" \
  --data-binary '{"query":"mutation($sch: String!) {\n updateGQLSchema(input: { set: { schema: $sch } })\n {\n gqlSchema {\n schema\n }\n }\n}","variables":{"sch": "type Person { name: String! }"}}' \
  --compressed

```

Thank you.

---

<div class="post-metadata">

**Author:** ![MichelDiz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/micheldiz/32/11873_2.png) [@MichelDiz](https://discuss.dgraph.io/u/MichelDiz)\
**Post date:** [August 27, 2021, 3:37pm UTC](https://discuss.dgraph.io/t/how-can-i-import-a-schema-in-graphql-file-using-api/15403/2 "2021-08-27T15:37:58Z")

</div>

> [@smolto](#):
>
> `"https://${DEPLOYMENT_URL}/admin"`

have you tried `https://${DEPLOYMENT_URL}/admin/schema`?

---

<div class="post-metadata">

**Author:** ![dmai](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/dmai/32/1254_2.png) [@dmai](https://discuss.dgraph.io/u/dmai)\
**Post date:** [August 27, 2021, 3:52pm UTC](https://discuss.dgraph.io/t/how-can-i-import-a-schema-in-graphql-file-using-api/15403/4 "2021-08-27T15:52:49Z")

</div>

Hi @smolto you’re right that in Dgraph Cloud the endpoint `/admin/schema` isn’t available. Building on top of your script, you can use the following command using both `curl` and `jq` to read your `schema.graphql` file and load it via the `/admin` endpoint.

```bash
#!/usr/bin/env bash

DEPLOYMENT_URL="polished-violet.us-east-1.aws.cloud.dgraph.io"
DEPLOYMENT_JWT="<deployment-jwt>"

jq -n --rawfile schema schema.graphql '{ query: "mutation updateGQLSchema($sch: String!) { updateGQLSchema(input: { set: { schema: $sch }}) { gqlSchema { schema } } }", variables: { sch: $schema }}' | 
    curl "https://${DEPLOYMENT_URL}/admin" \
         -H "Content-Type: application/json" \
         -H "X-Auth-Token: ${DEPLOYMENT_JWT}" \
         --data-binary @- \
         --compressed

```

---

<div class="post-metadata">

**Author:** ![aman-bansal](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/aman-bansal/32/4475_2.png) [@aman-bansal](https://discuss.dgraph.io/u/aman-bansal)\
**Post date:** [September 24, 2021, 9:44am UTC](https://discuss.dgraph.io/t/how-can-i-import-a-schema-in-graphql-file-using-api/15403/5 "2021-09-24T09:44:47Z")

</div>

Hi guys, `/admin/schema` is now available in cloud. Do let me know if face any issues.
