# \[resolved\] Create postgres datasource using API

**URL:** <https://community.grafana.com/t/resolved-create-postgres-datasource-using-api/14990>\
**Category:** Grafana\
**Created:** [March 4, 2019, 4:12pm UTC](https://community.grafana.com/t/resolved-create-postgres-datasource-using-api/14990 "2019-03-04T16:12:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![toms130](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/toms130/32/103_2.png) [@toms130](https://community.grafana.com/u/toms130)\
**Post date:** [March 4, 2019, 4:12pm UTC](https://community.grafana.com/t/resolved-create-postgres-datasource-using-api/14990/1 "2019-03-04T16:12:18Z")

</div>

Hi all,  
i’m trying to add a new datasource using API (I have to deploy it on ~300 different orgs so it must be scripted), but I can’t finc the way to set password.

I’ve tried password field with no success.  
I tried to put password in “jsonData” , but it does not work neither

When I curl API (get) on an existing postgres datasource, I get

{  
“user” : “grafanareader”,  
“url” : “[db.mycompany.com:9999](http://db.mycompany.com:9999)”,  
“access” : “proxy”,  
“id” : 2143,  
“database” : “base”,  
“jsonData” : {  
“keepCookies” : [],  
“sslmode” : “require”  
},  
“password” : “”,  
“orgId” : 1,  
“readOnly” : false,  
“typeLogoUrl” : “public/app/plugins/datasource/postgres/img/postgresql\_logo.svg”,  
“type” : “postgres”,  
“basicAuth” : false,  
“name” : “PG\_DB”,  
“isDefault” : false  
}

When I try to post the same thing with a value in password field, and access it into grafana, password field is empty.

If I curl again this new created datasource, I see my password in password field…

Any idea ?

---

<div class="post-metadata">

**Author:** ![toms130](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/toms130/32/103_2.png) [@toms130](https://community.grafana.com/u/toms130)\
**Post date:** [March 4, 2019, 4:22pm UTC](https://community.grafana.com/t/resolved-create-postgres-datasource-using-api/14990/2 "2019-03-04T16:22:46Z")

</div>

resolved, I had to use secureJsonData field.

“secureJsonData”: {  
“password”: “abcdef”  
},
