# Creating and Adding Values to \`custom\_fields\` via API

**URL:** <https://meta.discourse.org/t/creating-and-adding-values-to-custom-fields-via-api/93477>\
**Category:** Product Support\
**Created:** [July 30, 2018, 2:00pm UTC](https://meta.discourse.org/t/creating-and-adding-values-to-custom-fields-via-api/93477 "2018-07-30T14:00:58Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Curtis\_Kephart](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/curtis_kephart/32/89070_2.png) [@Curtis\_Kephart](https://meta.discourse.org/u/Curtis_Kephart)\
**Post date:** [July 30, 2018, 2:00pm UTC](https://meta.discourse.org/t/creating-and-adding-values-to-custom-fields-via-api/93477/1 "2018-07-30T14:00:58Z")

</div>

I am curious if there is any way to create and update Custom user fields (ie `users` \>\> `custom_field`) via the discourse API?

**Accessing `custon_fields`** - [Discourse’s docs show how to access `custom_fields` via `GET https://discourse.example.com/users/{username}.json`.](https://docs.discourse.org/#tag/Users%2Fpaths%2F~1users~1%7Busername%7D.json%2Fget).

**Updating `user_fields`** - This discussion [“API: cannot update user” walks through how to use the API to PUT/update fields like `name` and `user_fields` (user fields created at admin/customize/user\_fields)](https://meta.discourse.org/t/api-cannot-update-user/63876).

But for the life of me, I cannot construct a working curl example in which `custon_fields` is created or updated.

For example,

```plaintext
curl -X "PUT" "https://{myDomain}/users/{username}.json?api_key= ***&api_username=***" \
     -H "Content-Type: application/json" \
     -d $'{
  "custom_fields":{"test-val":"0.1"}
}`

```

Returns the following, which looks similar to a successful PUT (e.g. updating `name` or updating already-created `user_fields`).  
However, `custom_fields` is not updated.

```plaintext
...
> Accept: application/json, text/xml, application/xml, */*
-> 
<- HTTP/1.1 200 OK
<- Server: nginx
<- Date: Mon, 30 Jul 2018 13:57:02 GMT
<- Content-Type: application/json; charset=utf-8
<- Transfer-Encoding: chunked
<- Connection: keep-alive
<- Vary: Accept-Encoding
<- X-Frame-Options: SAMEORIGIN
<- X-XSS-Protection: 1; mode=block
<- X-Content-Type-Options: nosniff
<- X-Download-Options: noopen
<- X-Permitted-Cross-Domain-Policies: none
<- Referrer-Policy: strict-origin-when-cross-origin
<- X-Discourse-Username: EconomiCurtis
<- X-Discourse-Route: users/show
<- Cache-Control: no-store, must-revalidate, private, max-age=0
....

```

---

_[View the full topic](https://meta.discourse.org/t/creating-and-adding-values-to-custom-fields-via-api/93477)._
