# I can't add a template from the CLI

**URL:** <https://drone.discourse.group/t/i-cant-add-a-template-from-the-cli/12113>\
**Category:** Drone Support\
**Created:** [June 5, 2022, 5:42am UTC](https://drone.discourse.group/t/i-cant-add-a-template-from-the-cli/12113 "2022-06-05T05:42:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryanjaeb](https://avatars.discourse-cdn.com/v4/letter/r/aca169/32.png) [@ryanjaeb](https://drone.discourse.group/u/ryanjaeb)\
**Post date:** [June 5, 2022, 5:42am UTC](https://drone.discourse.group/t/i-cant-add-a-template-from-the-cli/12113/1 "2022-06-05T05:42:46Z")

</div>

I’m trying to test out the way templates work and I’m having trouble with the basics. I’m using the CLI tools v1.5.0 and configured them as shown [here](https://docs.drone.io/cli/configure/). I can list templates if I add them via the web interface.

I want to add a simple YAML template, but the syntax described in [the docs](https://docs.drone.io/template/yaml/) doesn’t work. For example:

```nohighlight
drone template add ryanjaeb my_template mytemplate.yaml

```

Outputs:

```auto
missing namespace

```

I need to use the options syntax described [here](https://docs.drone.io/cli/template/drone-template-add/). Ex:

```nohighlight
drone template add --namespace ryanjaeb --name my_template mytemplate.yaml

```

However, I can never get past the following error, no matter what kind of syntax I try for supplying the file name.

```auto
client error 400: {"message":"Template extension invalid. Must be yaml, starlark or jsonnet"}

```

I’ve tried it in both Windows and Linux. What am I doing wrong?

I’m also wondering how the namespaces are scoped. In the UI, I have to add a template from the settings of a project, but it’s under the organization section. Does that mean the template is only usable for that project or can I use it for any project in the organization? Also, is there a way to have a globally usable template?

Thanks in advance for the help!

---

<div class="post-metadata">

**Author:** ![brad](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/brad/32/4172_2.png) [@brad](https://drone.discourse.group/u/brad)\
**Post date:** [June 5, 2022, 3:56pm UTC](https://drone.discourse.group/t/i-cant-add-a-template-from-the-cli/12113/2 "2022-06-05T15:56:20Z")

</div>

The template name must include a valid extension, in this case yaml. The reason is that Drone supports multiple template formats (yaml, jsonnet, etc) and requires an extension to properly identify the template format at runtime.

```diff
-drone template add --namespace ryanjaeb --name my_template mytemplate.yaml
+drone template add --namespace ryanjaeb --name my_template.yaml @/path/to/mytemplate.yaml

```

---

<div class="post-metadata">

**Author:** ![ryanjaeb](https://avatars.discourse-cdn.com/v4/letter/r/aca169/32.png) [@ryanjaeb](https://drone.discourse.group/u/ryanjaeb)\
**Post date:** [June 5, 2022, 6:18pm UTC](https://drone.discourse.group/t/i-cant-add-a-template-from-the-cli/12113/3 "2022-06-05T18:18:36Z")

</div>

Thanks. I had to use the options style syntax for data (`--data "@{PWD}/mytemplate.yaml"`) rather than the argument style syntax, but the missing extension on the name was the main thing tripping me up.
