# Scope user/document.read and user/document.write not available while registering API Client

**URL:** <https://community.open-emr.org/t/scope-user-document-read-and-user-document-write-not-available-while-registering-api-client/25353>\
**Category:** Support\
**Tags:** api, installation\
**Created:** [April 22, 2025, 7:40am UTC](https://community.open-emr.org/t/scope-user-document-read-and-user-document-write-not-available-while-registering-api-client/25353 "2025-04-22T07:40:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![soban.momin](https://community.open-emr.org/letter_avatar_proxy/v4/letter/s/db5fbb/32.png) [@soban.momin](https://community.open-emr.org/u/soban.momin)\
**Post date:** [April 22, 2025, 7:40am UTC](https://community.open-emr.org/t/scope-user-document-read-and-user-document-write-not-available-while-registering-api-client/25353/1 "2025-04-22T07:40:33Z")

</div>

**Situation**  
The scopes “user/document.read” and “user/document.write” are not available while registering API Client.

**OpenEMR Version**  
I’m using docker to run OpenEMR version 7.0.3

**Browser** :  
Chrome version 124.0.6367.119.

**Operating System**  
Windows 11 Pro

**Logs**  
I don’t see anything in logs.

Please note I have enabled the following four options under Admin → Config → Connectors

Enable OpenEMR Standard FHIR REST API  
Enable OpenEMR FHIR System Scopes (Turn on only if you know what you are doing)  
Enable OpenEMR Standard REST API  
Enable OpenEMR Patient Portal REST API (EXPERIMENTAL)

Any help will be aapreciated.

---

<div class="post-metadata">

**Author:** ![Nilesh\_Hake](https://community.open-emr.org/user_avatar/community.open-emr.org/nilesh_hake/32/13927_2.png) [@Nilesh\_Hake](https://community.open-emr.org/u/Nilesh_Hake)\
**Post date:** [April 23, 2025, 7:24am UTC](https://community.open-emr.org/t/scope-user-document-read-and-user-document-write-not-available-while-registering-api-client/25353/2 "2025-04-23T07:24:35Z")

</div>

@soban.momin You have to update this scope into your database as well if you have already registered the client

---

<div class="post-metadata">

**Author:** ![soban.momin](https://community.open-emr.org/letter_avatar_proxy/v4/letter/s/db5fbb/32.png) [@soban.momin](https://community.open-emr.org/u/soban.momin)\
**Post date:** [April 23, 2025, 9:33am UTC](https://community.open-emr.org/t/scope-user-document-read-and-user-document-write-not-available-while-registering-api-client/25353/3 "2025-04-23T09:33:51Z")

</div>

@Nilesh_Hake I want to register a new client. Can you please guide me with the reference doc on how to add scopes to database?

---

<div class="post-metadata">

**Author:** ![Nilesh\_Hake](https://community.open-emr.org/user_avatar/community.open-emr.org/nilesh_hake/32/13927_2.png) [@Nilesh\_Hake](https://community.open-emr.org/u/Nilesh_Hake)\
**Post date:** [April 23, 2025, 10:02am UTC](https://community.open-emr.org/t/scope-user-document-read-and-user-document-write-not-available-while-registering-api-client/25353/4 "2025-04-23T10:02:19Z")

</div>

@soban.momin Yes sure please send me email on below email id [nilesh.hake@nbhhealthsoft.com](mailto:nilesh.hake@nbhhealthsoft.com)

---

<div class="post-metadata">

**Author:** ![Qiaben](https://community.open-emr.org/user_avatar/community.open-emr.org/qiaben/32/21612_2.png) [@Qiaben](https://community.open-emr.org/u/Qiaben)\
**Post date:** [April 23, 2025, 12:07pm UTC](https://community.open-emr.org/t/scope-user-document-read-and-user-document-write-not-available-while-registering-api-client/25353/5 "2025-04-23T12:07:16Z")

</div>

Thought for 27 seconds

It turns out this isn’t actually a FHIR bug or a missing feature in your Docker image, but rather a quirk of the built-in “Admin → System → API Clients” UI: it doesn’t list every scope that OpenEMR supports by default. To work around it, you need to bypass the broken UI and register your client directly against the OAuth2 server.

Double‐check your Connector settings  
In Admin → Config → Connectors, make sure you have:

Site Address (required for OAuth2 and FHIR) set to your OpenEMR base URI (e.g. https:///emr)

☑ Enable OpenEMR Standard REST API

☑ Enable OpenEMR Patient Portal REST API (EXPERIMENTAL) (if you need portal scopes)

☑ Enable OpenEMR FHIR REST API (not strictly needed for the standard API scopes, but harmless)

☑ Enable OpenEMR FHIR System Scopes (only for system-level FHIR scopes)  
– and Save. citeturn2view0

Register your OAuth2 client via the registration endpoint  
Open your browser’s Developer Console (right-click → Inspect → Console) and paste in a fetch call like the one below. Substitute https:///emr with your actual OpenEMR URL, and update redirect\_uris/client\_name as desired. Note how we explicitly include user/document.read and user/document.write in the scope string. citeturn3view0

(async() =\> {

const resp = await fetch(“https:///emr/oauth2/default/registration”, {

```
credentials: "include", 

headers: { "Content-Type": "application/json" }, 

method: "POST", 

body: JSON.stringify({ 

  application_type: "private", 

  redirect_uris: ["https://yourapp.example.com/callback"], 

  post_logout_redirect_uris: [""], 

  initiate_login_uri: "", 

  client_name: "My OpenEMR API Client", 

  token_endpoint_auth_method: "client_secret_post", 

  contacts: ["devteam@example.com"], 

  scope: [ 

    "openid", 

    "offline_access", 

    "api:oemr", 

    // include all the user/* scopes you need: 

    "user/appointment.read", 

    "user/appointment.write", 

    "user/document.read", 

    "user/document.write", 

    // …etc… 

  ].join(" ") 

}) 

```

});

console.log(await resp.json());

})();

That will print out a JSON object containing your new client\_id and client\_secret.

Enable the client in the Admin UI

Go back to Admin → System → API Clients.

You should now see “My OpenEMR API Client” in the list.

Click Edit, then toggle it Enabled, and Save.

After that, you’ll be able to request tokens with the document scopes:

curl -X POST https:///emr/oauth2/default/token \

-u client\_id:client\_secret \

-d grant\_type=client\_credentials \

-d scope=“user/document.read user/document.write”

and subsequently call your /api/document/… endpoints with those permissions.

---

<div class="post-metadata">

**Author:** ![adunsulag](https://community.open-emr.org/user_avatar/community.open-emr.org/adunsulag/32/12606_2.png) [@adunsulag](https://community.open-emr.org/u/adunsulag)\
**Post date:** [April 23, 2025, 1:25pm UTC](https://community.open-emr.org/t/scope-user-document-read-and-user-document-write-not-available-while-registering-api-client/25353/6 "2025-04-23T13:25:49Z")

</div>

> [@Qiaben](#):
>
> To work around it, you need to bypass the broken UI and register your client directly against the OAuth2 server.

The UI is not broken. It was designed for FHIR client registration and only supports FHIR scopes. If anyone wants to ENHANCE the GUI registration they can add the other scopes and send us a PR.

The API Readme has the docs for registering directly with the server. A simple HTTP Post request using CURL, postman, whatever client you want will do the registration.

---

<div class="post-metadata">

**Author:** ![soban.momin](https://community.open-emr.org/letter_avatar_proxy/v4/letter/s/db5fbb/32.png) [@soban.momin](https://community.open-emr.org/u/soban.momin)\
**Post date:** [May 2, 2025, 10:13am UTC](https://community.open-emr.org/t/scope-user-document-read-and-user-document-write-not-available-while-registering-api-client/25353/7 "2025-05-02T10:13:17Z")

</div>

Thanks @adunsulag . I am able to access the documents scope by registering the client using API. It would be nice if you can put this in the documentation.

> The UI is not broken. It was designed for FHIR client registration and only supports FHIR scopes.
