# How to store configuration properties in a Confluence Cloud app?

**URL:** <https://community.developer.atlassian.com/t/how-to-store-configuration-properties-in-a-confluence-cloud-app/15693>\
**Category:** Confluence Cloud\
**Created:** [March 6, 2018, 5:26am UTC](https://community.developer.atlassian.com/t/how-to-store-configuration-properties-in-a-confluence-cloud-app/15693 "2018-03-06T05:26:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ppasler](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/ppasler/32/49174_2.png) [@ppasler](https://community.developer.atlassian.com/u/ppasler)\
**Post date:** [March 6, 2018, 5:26am UTC](https://community.developer.atlassian.com/t/how-to-store-configuration-properties-in-a-confluence-cloud-app/15693/1 "2018-03-06T05:26:59Z")

</div>

I followed the tutorial ti add a new Confluence cloud app: [Tutorials, example apps, and guides](https://developer.atlassian.com/cloud/confluence/tutorials-and-guides/)

I am looking for a way to store configration data (simple key.value pairs) in Confluence Cloud app. So I’ve found this: [App properties API](https://developer.atlassian.com/cloud/confluence/app-properties-api/)

I am writing a expressjs app and added the following snippet into my index.js

```auto
app.get('/random-page-admin', addon.authenticate(), function (req, res) {
   var userKey = req.query['user_key'];
   var clientKey = req.context.clientKey;

   getHTTPClient(clientKey, userKey).put(
      '/rest/atlassian-connect/1/addons/random-page-cloud/properties/pages-limit',
      function (err, response, contents) {

         if (err || (response.statusCode < 200 || response.statusCode > 299)) {
            res.render('<strong>An error has occurred :( ' + response.statusCode + '</strong>');
            return;
         }

         contents = JSON.parse(contents);

         res.render('admin/random-page-admin', {});
      }
   );

});

```

Result:

`{"status-code":404,"message":"Add-on with key does not exist."}`

---

<div class="post-metadata">

**Author:** ![ppasler](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/ppasler/32/49174_2.png) [@ppasler](https://community.developer.atlassian.com/u/ppasler)\
**Post date:** [March 7, 2018, 1:21pm UTC](https://community.developer.atlassian.com/t/how-to-store-configuration-properties-in-a-confluence-cloud-app/15693/2 "2018-03-07T13:21:38Z")

</div>

Although the answer “Add-on with key does not exist.” points to a wrong add-on key, in my case the problem was the context. As the [app-properties-api documentation](https://developer.atlassian.com/cloud/confluence/app-properties-api/) sais

> Request issued by a user with insufficient credentials, e.g. for an app’s data by anyone but the app itself, or for a app that does not exist.

Where the interesting part in my case was “for an app’s data by anyone but the app itself” meaning that the requests have to be send within the app (a simple GET request from the browser will fail with the given error)

I had to send the request from within the app (index.js). First a PUT and then a GET for the property

```auto
app.get('/store', addon.authenticate(), function (req, res) {
   var userKey = req.query['user_key'];
   var clientKey = req.context.clientKey;

   var options = {
      headers: {
         'X-Atlassian-Token': 'nocheck'
      },
      url: '/rest/atlassian-connect/1/addons/<add-on-key>/properties/<property-key>',
      json: 'true'
   };

   getHTTPClient(clientKey, userKey).put(options,
      function (err, response, contents) {
         getHTTPClient(clientKey, userKey).get(
            '/rest/atlassian-connect/1/addons/<add-on-key>/properties/<property-key>',
            function (err, response, contents) {
               contents = JSON.parse(contents);
               res.render('test', {
                  'test': contents,
                  'status': response.statusCode
               });
            });
      });
});

function getHTTPClient(clientKey, userKey) {
   return addon.httpClient({
      clientKey: clientKey,
      userKey: userKey,
      appKey: addon.key
   });
}

```

This just a simple example and not meatn for production 🙂
