# Creating (or editing/deleting) TTN applications using the API

**URL:** <https://www.thethingsnetwork.org/forum/t/creating-or-editing-deleting-ttn-applications-using-the-api/48574>\
**Category:** Uncategorized\
**Created:** [June 8, 2021, 7:26am UTC](https://www.thethingsnetwork.org/forum/t/creating-or-editing-deleting-ttn-applications-using-the-api/48574 "2021-06-08T07:26:47Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![LoRa\_AuH](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/lora_auh/32/35697_2.png) [@LoRa\_AuH](https://www.thethingsnetwork.org/forum/u/LoRa_AuH)\
**Post date:** [June 8, 2021, 7:26am UTC](https://www.thethingsnetwork.org/forum/t/creating-or-editing-deleting-ttn-applications-using-the-api/48574/1 "2021-06-08T07:26:47Z")

</div>

Hello all,  
I’m looking for a way to create or edit TTN applications using the API.  
I’ve read the docs but it’s still somehow confusing to find a simple start  
method to perform this (using PHP), so I’m looking for some examples  
on how to start with this. Thanks a lot for any hints.  
Ralf

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [June 8, 2021, 7:38am UTC](https://www.thethingsnetwork.org/forum/t/creating-or-editing-deleting-ttn-applications-using-the-api/48574/2 "2021-06-08T07:38:42Z")

</div>

As this is in the uncategorised section, which version of TTN?

---

<div class="post-metadata">

**Author:** ![LoRa\_AuH](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/lora_auh/32/35697_2.png) [@LoRa\_AuH](https://www.thethingsnetwork.org/forum/u/LoRa_AuH)\
**Post date:** [June 8, 2021, 8:10am UTC](https://www.thethingsnetwork.org/forum/t/creating-or-editing-deleting-ttn-applications-using-the-api/48574/3 "2021-06-08T08:10:30Z")

</div>

Hello descartes,  
that’s sort of a quick reply.  
Of course I moved all my applications, devices and gateways  
to TTN v3.In a first step, I would like to create or delete applications remotely  
via my dashboard.  
Kind regards  
Ralf

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [June 8, 2021, 9:20am UTC](https://www.thethingsnetwork.org/forum/t/creating-or-editing-deleting-ttn-applications-using-the-api/48574/4 "2021-06-08T09:20:14Z")

</div>

> [@LoRa\_AuH](#):
>
> that’s sort of a quick reply.

Safari notifications and as a moderator I (briefly) read all the posts and **we** have an active thread on device creation and apart from general LoRaWAN experience, integrations is one of my areas of expertise (my superpower is reading the manual)

I’ll look at my game plan for samples, I know it’s not got exactly what you need right now but will give you some idea of what I’ve got in mind, but here’s what I’ve published so far:

> **[GitHub - descartes/TheThingsStack-Integration-Starters: Starter / Template...](https://github.com/descartes/TheThingsStack-Integration-Starters)**
>
> Starter / Template code for various The Things Stack (v3) integrations - descartes/TheThingsStack-Integration-Starters

So I’m happy to start on an TheThingsStack-API-Starters as I have a fair amount in Python already and PHP is just another imperative language that I code in reasonably frequently, so we can turn this and your device creation issue in to a proper piece of work.

My iMac now has a nice shiny new copy of macOS (Catalina) on it and most of the day to day apps are installed and I need a bit of break from paid-work so lets see if we can’t get this done in the next 24 hours.

---

<div class="post-metadata">

**Author:** ![LoRa\_AuH](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/lora_auh/32/35697_2.png) [@LoRa\_AuH](https://www.thethingsnetwork.org/forum/u/LoRa_AuH)\
**Post date:** [June 8, 2021, 1:59pm UTC](https://www.thethingsnetwork.org/forum/t/creating-or-editing-deleting-ttn-applications-using-the-api/48574/5 "2021-06-08T13:59:32Z")

</div>

OK descartes, thanks a lot.

---

<div class="post-metadata">

**Author:** ![LoRa\_AuH](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/lora_auh/32/35697_2.png) [@LoRa\_AuH](https://www.thethingsnetwork.org/forum/u/LoRa_AuH)\
**Post date:** [June 10, 2021, 9:42am UTC](https://www.thethingsnetwork.org/forum/t/creating-or-editing-deleting-ttn-applications-using-the-api/48574/6 "2021-06-10T09:42:10Z")

</div>

Hello everyone,

I want to create an application in TTN V3 via HTTP Post API. I read the documentation and know, how to make an HTTP Post request to make a new application in TTN. But I am struggling to set up the JSON data that I have to send with my Post request.

Does anyone have a sample JSON data so that I can debug mine and find the error? Maybe someone knows any link where I can read and can correct me. Thank you so much.

Kind regards  
Imran Khan

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [June 10, 2021, 10:03am UTC](https://www.thethingsnetwork.org/forum/t/creating-or-editing-deleting-ttn-applications-using-the-api/48574/7 "2021-06-10T10:03:37Z")

</div>

I’m assuming the excitement of getting devices working means you forgot about this thread you started a couple of days ago …

---

<div class="post-metadata">

**Author:** ![LoRa\_AuH](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/lora_auh/32/35697_2.png) [@LoRa\_AuH](https://www.thethingsnetwork.org/forum/u/LoRa_AuH)\
**Post date:** [June 10, 2021, 10:08am UTC](https://www.thethingsnetwork.org/forum/t/creating-or-editing-deleting-ttn-applications-using-the-api/48574/8 "2021-06-10T10:08:37Z")

</div>

Good morning descartes,

Thank you so much, because of you my devices are working now. My apology for repeating the same post. Actually, this post was made by my colleague, and I didn’t know about that. I will have a look at the discussion.

Kind regards  
Imran Khan

---

<div class="post-metadata">

**Author:** ![LoRa\_AuH](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/lora_auh/32/35697_2.png) [@LoRa\_AuH](https://www.thethingsnetwork.org/forum/u/LoRa_AuH)\
**Post date:** [June 10, 2021, 10:20am UTC](https://www.thethingsnetwork.org/forum/t/creating-or-editing-deleting-ttn-applications-using-the-api/48574/9 "2021-06-10T10:20:42Z")

</div>

> [@descartes](#):
>
> So I’m happy to start on an TheThingsStack-API-Starters as I have a fair amount in Python already and PHP is just another imperative language that I code in reasonably frequently, so we can turn this and your device creation issue in to a proper piece of work.

I will be very pleased to work with you to do something better for the TTN Community. I am basically an IoT & PHP Full Stack Developer and Python is already in my lerning list. I will have a look at your repository and will be in contact with you.

---

<div class="post-metadata">

**Author:** ![Jeff-UK](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jeff-uk/32/35697_2.png) [@Jeff-UK](https://www.thethingsnetwork.org/forum/u/Jeff-UK)\
**Post date:** [June 10, 2021, 10:23am UTC](https://www.thethingsnetwork.org/forum/t/creating-or-editing-deleting-ttn-applications-using-the-api/48574/10 "2021-06-10T10:23:28Z")

</div>

> [@LoRa\_AuH](#):
>
> Actually, this post was made by my colleague

As standard, and as good practice - anywhere in the Inet!, we recommend you _dont_ share user names and passwords… its trivial to set up a new account for aternate users. We have organizations and collaborators options to allow, well, collaboration & sharing and you can always copy a fellow user using thier @‘username’ tag so all aware of activity/avoid duplication and splitting of efforts…

---

<div class="post-metadata">

**Author:** ![LoRa\_AuH](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/lora_auh/32/35697_2.png) [@LoRa\_AuH](https://www.thethingsnetwork.org/forum/u/LoRa_AuH)\
**Post date:** [June 10, 2021, 1:40pm UTC](https://www.thethingsnetwork.org/forum/t/creating-or-editing-deleting-ttn-applications-using-the-api/48574/11 "2021-06-10T13:40:57Z")

</div>

The procedure to create an Application using HTTP Post request is given below.

I am using PHP so I first prepared an array as given below.

```
$appReg = [
                'application' => [
                    'ids' => [
                        'application_id' => $this->appId
                    ],
                    'name' => $this->appName,
                    'description' => $this->description
                ],
                'field_mask' => [
                    'paths' => [
                        'ids.application_id',
                        'name',
                        'description'
                    ]
                ]
            ];

```

I converted my array to JSON as given below using json\_encode()

`$app_registration = json_encode($appReg);`

Post URL is as given

> $url = ‘[https://eu1.cloud.thethings.network/api/v3/users/my\_user/applications](https://eu1.cloud.thethings.network/api/v3/users/my_user/applications)’

and just made cURL Post as given below

```
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array($authorization, 'Content-Type: application/json'));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $app_registration);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$result = curl_exec($ch);
curl_close($ch);

```
