# Import/Export Client Scopes in a realm

**URL:** <https://forum.keycloak.org/t/import-export-client-scopes-in-a-realm/9612>\
**Category:** Getting advice\
**Created:** [June 16, 2021, 8:01am UTC](https://forum.keycloak.org/t/import-export-client-scopes-in-a-realm/9612 "2021-06-16T08:01:28Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![divya](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@divya](https://forum.keycloak.org/u/divya)\
**Post date:** [June 16, 2021, 8:01am UTC](https://forum.keycloak.org/t/import-export-client-scopes-in-a-realm/9612/1 "2021-06-16T08:01:28Z")

</div>

Hello,

Is there a way to import client Scopes in a realm ?

Thanks for the help.

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [June 16, 2021, 10:57am UTC](https://forum.keycloak.org/t/import-export-client-scopes-in-a-realm/9612/2 "2021-06-16T10:57:24Z")

</div>

Can you provide more detail? The realm import functionality will import Client Scopes if they are present in the realm json file you are importing.

---

<div class="post-metadata">

**Author:** ![divya](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@divya](https://forum.keycloak.org/u/divya)\
**Post date:** [June 16, 2021, 11:29am UTC](https://forum.keycloak.org/t/import-export-client-scopes-in-a-realm/9612/3 "2021-06-16T11:29:56Z")

</div>

![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/2/2beddc2ff820ea7ed2e85b1f481348fec876b4ac.png)

I have added scope the way it is mentioned in the image above. If I am doing it wrong, please let know.

Thank you for your reply.

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [June 16, 2021, 11:50am UTC](https://forum.keycloak.org/t/import-export-client-scopes-in-a-realm/9612/4 "2021-06-16T11:50:44Z")

</div>

That looks right. However, are you doing it manually? Why not just create a realm in the admin UI, create and map the Client Scopes, and then export the realm?

[https://www.keycloak.org/docs-api/13.0/rest-api/index.html#\_clientscoperepresentation](https://www.keycloak.org/docs-api/13.0/rest-api/index.html#_clientscoperepresentation)

---

<div class="post-metadata">

**Author:** ![divya](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@divya](https://forum.keycloak.org/u/divya)\
**Post date:** [June 16, 2021, 11:59am UTC](https://forum.keycloak.org/t/import-export-client-scopes-in-a-realm/9612/5 "2021-06-16T11:59:49Z")

</div>

Actually I have to use import functionality because I have created different realms but client scopes in all of them are same. So instead of creating it every time I thought to import it.

However, can you elaborate on your point: Why not just create a realm in the admin UI, create and map the Client Scopes, and then export the realm?

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [June 16, 2021, 12:11pm UTC](https://forum.keycloak.org/t/import-export-client-scopes-in-a-realm/9612/6 "2021-06-16T12:11:17Z")

</div>

There is a section of the Admin UI called “Export”, where you can export the realm. Check “Export clients” when you are exporting, so that it will include Clients and Client Scopes:

 ![Screen Shot 2021-06-16 at 2.09.31 PM](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/6/67d741c6406fc1e0cd900812fda8694d1b6add89.png)  
Once you have done that, you can use that file to import the realm elsewhere.

---

<div class="post-metadata">

**Author:** ![divya](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@divya](https://forum.keycloak.org/u/divya)\
**Post date:** [June 16, 2021, 12:29pm UTC](https://forum.keycloak.org/t/import-export-client-scopes-in-a-realm/9612/7 "2021-06-16T12:29:47Z")

</div>

I totally got the export feature.

Now, for example:  
I have 2 realms: one is “demo” and another is “demo1”. I created a scope “sample-scope” in demo realm using the section of the Admin UI called “Client Scopes”. And now I want the same client scope in realm “demo1”. So I exported realm json files of both the realms and then I copied the “sample-scope” curl data from “demo” realm json file and pasted in “demo1” realm json file. Now I imported the demo1 realm json file but the scope was not imported.

Is it the proper way ?

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [June 16, 2021, 1:09pm UTC](https://forum.keycloak.org/t/import-export-client-scopes-in-a-realm/9612/8 "2021-06-16T13:09:06Z")

</div>

> [@divya](#):
>
> pasted in “demo1” realm json file

That should work. Do you see any errors in the Keycloak logs?

---

<div class="post-metadata">

**Author:** ![divya](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@divya](https://forum.keycloak.org/u/divya)\
**Post date:** [June 16, 2021, 1:30pm UTC](https://forum.keycloak.org/t/import-export-client-scopes-in-a-realm/9612/9 "2021-06-16T13:30:19Z")

</div>

No, there are no errors. File gets imported successfully.

---

<div class="post-metadata">

**Author:** ![divya](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@divya](https://forum.keycloak.org/u/divya)\
**Post date:** [June 17, 2021, 6:21am UTC](https://forum.keycloak.org/t/import-export-client-scopes-in-a-realm/9612/10 "2021-06-17T06:21:35Z")

</div>

While importing I only get three options which are mentioned in the image attached below:

![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/8/8b5a3a0b0c62d62dc8558c486b07d3041df13c30.png)

---

<div class="post-metadata">

**Author:** ![taotao100](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/taotao100/32/4795_2.png) [@taotao100](https://forum.keycloak.org/u/taotao100)\
**Post date:** [January 13, 2022, 2:15pm UTC](https://forum.keycloak.org/t/import-export-client-scopes-in-a-realm/9612/11 "2022-01-13T14:15:43Z")

</div>

as divya mentioned above, I have same issue, that the configurations of client-scopes exported in json could not be imported in realm.

---

<div class="post-metadata">

**Author:** ![carlin](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/carlin/32/6978_2.png) [@carlin](https://forum.keycloak.org/u/carlin)\
**Post date:** [March 2, 2023, 1:56am UTC](https://forum.keycloak.org/t/import-export-client-scopes-in-a-realm/9612/12 "2023-03-02T01:56:13Z")

</div>

Is there any update on this? I have a fairly complex client scope that I’d like to import into each realm, but the import does not import it. No errors in my logs.

I have no issues exporting the client scope from my template realm.

---

<div class="post-metadata">

**Author:** ![ilanigi](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/ilanigi/32/11253_2.png) [@ilanigi](https://forum.keycloak.org/u/ilanigi)\
**Post date:** [September 15, 2024, 10:03am UTC](https://forum.keycloak.org/t/import-export-client-scopes-in-a-realm/9612/13 "2024-09-15T10:03:08Z")

</div>

I’m facing the same issue: I’m trying to import a few client scops from a valid exported JSON file.  
I found a workaround for my situation.  
In my case, on bootstrap, I’m reconfiguring keycloak from another server, that will later use it.  
So after importing the successful part I’m using the management module (in node.js, in my case) and creating them manually, using the very same attributes from the JSON file - no modification is needed, only adding the realm name.
