# Unable to edit topic via API despite topic write access

**URL:** https://meta.discourse.org/t/unable-to-edit-topic-via-api-despite-topic-write-access/219805
**Category:** Bug
**Tags:** rest-api
**Created:** [March 2, 2022, 8:32am UTC](https://meta.discourse.org/t/unable-to-edit-topic-via-api-despite-topic-write-access/219805 "2022-03-02T08:32:53Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![mkows](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mkows/32/251661_2.png) [@mkows](https://meta.discourse.org/u/mkows)
#### Post date: [March 2, 2022, 8:32am UTC](https://meta.discourse.org/t/unable-to-edit-topic-via-api-despite-topic-write-access/219805/1 "2022-03-02T08:32:54Z")

</div>

Hey all,

I noticed that, despite having Topic Write access, I am not allowed to edit topic’s title.  
This seem to only work when API key has a global scope.

With API key that has the following permission scopes:

 ![Screenshot 2022-03-02 at 12.29.46](https://global.discourse-cdn.com/meta/original/3X/1/3/1343007ae5e9e44d3bf2a0beb21adb56301bc326.jpeg)

I am getting:

```plaintext
curl 'https:// __NAME__.discourse.team/t/-/19.json' \
  -H "Api-Key: 3990a1..." \
  -H "Api-Username: system" \
  -H "Content-Type: application/json" \
  -X PUT \
  -d "{ \"title\": \"Title - test curl v5\" }"

{"errors":["You are not permitted to view the requested resource. The API username or key is invalid."],"error_type":"invalid_access"}

```

And I get the same response when I select all granular scopes.

Only when creating an API key with Scope: Global, I manage to edit topic’s title:

```plaintext
curl 'https:// __NAME__.discourse.team/t/-/19.json' \
  -H "Api-Key: 0adc49d..." \
  -H "Api-Username: system" \
  -H "Content-Type: application/json" \
  -X PUT \
  -d "{ \"title\": \"Title - test curl v5\" }"

{"basic_topic":{"id":19,"title":"Title - test curl v5","fancy_title":"Title - test curl v5","slug":"title-test-curl-v5","posts_count":2}}

```

I would expect from topic write access to support edit operation. It seems to me like enforcing global scope for that is not desired.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [March 2, 2022, 12:17pm UTC](https://meta.discourse.org/t/unable-to-edit-topic-via-api-despite-topic-write-access/219805/2 "2022-03-02T12:17:59Z")

</div>

Are you trying to write a new topic or modify an existing one?

---

<div class="post-metadata">

### Author: ![mkows](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mkows/32/251661_2.png) [@mkows](https://meta.discourse.org/u/mkows)
#### Post date: [March 2, 2022, 1:35pm UTC](https://meta.discourse.org/t/unable-to-edit-topic-via-api-despite-topic-write-access/219805/3 "2022-03-02T13:35:22Z")

</div>

@pfaffman I am trying to edit topic’s title via update topic endpoint [Discourse API Docs](https://docs.discourse.org/#operation/updateTopic)

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [March 2, 2022, 6:03pm UTC](https://meta.discourse.org/t/unable-to-edit-topic-via-api-despite-topic-write-access/219805/5 "2022-03-02T18:03:40Z")

</div>

I’ll look into the api scoping for this. My guess is it is only looking at the POST request and not the PUT request for updating.

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [March 4, 2022, 6:50pm UTC](https://meta.discourse.org/t/unable-to-edit-topic-via-api-despite-topic-write-access/219805/6 "2022-03-04T18:50:04Z")

</div>

There is [now](https://github.com/discourse/discourse/commit/07e80b52ef6fa1dbfbba5227b93608c2931ab4d8) an **update topic** scope that you can use for this.

 ![image](https://global.discourse-cdn.com/meta/original/3X/0/c/0ca4d5197a760b19661cb72b2c66974db372e8d1.png)

```plaintext
curl -i -sS -X PUT "http://localhost:4200/t/-/101.json" \
-H "Content-Type: multipart/form-data" \
-H "Api-Key: 54096675ed84dcf0016a3b05199cccde67e5175057e53f8e005e2625940a15e6" \
-H "Api-Username: blake.erickson" \
-F "title=8bd599 cae3dfdbf 7210753"

HTTP/1.1 200 OK

```

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [March 7, 2022, 9:54pm UTC](https://meta.discourse.org/t/unable-to-edit-topic-via-api-despite-topic-write-access/219805/7 "2022-03-07T21:54:29Z")

</div>


