# Creating cluster with the API

**URL:** <https://discuss.elastic.co/t/creating-cluster-with-the-api/151063>\
**Category:** Elastic Cloud Enterprise (ECE)\
**Created:** [October 4, 2018, 2:53pm UTC](https://discuss.elastic.co/t/creating-cluster-with-the-api/151063 "2018-10-04T14:53:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JamesNotJamez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jamesnotjamez/32/45736_2.png) [@JamesNotJamez](https://discuss.elastic.co/u/JamesNotJamez)\
**Post date:** [October 4, 2018, 2:53pm UTC](https://discuss.elastic.co/t/creating-cluster-with-the-api/151063/1 "2018-10-04T14:53:47Z")

</div>

Hi,

When I create a new cluster using the API, passing the json below, I get 201 status that it's been accepted but in ECE the deployment crashes with the error 'Cannot read property 'plan' of null'.

```auto
 'kibana': {'cluster_name': 'py_kib',
            'plan': {'cluster_topology': [{'instance_configuration_id': 'kibana',
                                           'zone_count': 1}],
                     'kibana': {'version': '6.4.0'},
                     'transient': {},
                     'zone_count': 2}},
 'plan': {'cluster_topology': [{'instance_configuration_id': 'data.default',
                                'node_type': {'data': True,
                                              'ingest': True,
                                              'master': True,
                                              'ml': False},
                                'zone_count': 1},
                               {'instance_configuration_id': 'data.highstorage',
                                'node_type': {'data': True,
                                              'ingest': True,
                                              'master': True,
                                              'ml': False},
                                'zone_count': 1}],
          'elasticsearch': {'curation': {'from_instance_configuration_id': 'data.default',
                                         'to_instance_configuration_id': 'data.highstorage'},
                            'version': '6.4.0'},
          'tiebreaker_topology': {'memory_per_node': 1024}},
 'settings': {'curation': {'specs': []}}}

```

```auto
TypeError: Cannot read property 'plan' of null
    at t.value (http://10.117.142.216:12400/app.a61f89c1e4fc0148a088.js:1:1397553)
    at dn (http://10.117.142.216:12400/vendor.9b5136f2335ece1032af.js:59:35450)
    at Tn (http://10.117.142.216:12400/vendor.9b5136f2335ece1032af.js:59:47482)
    at Yn (http://10.117.142.216:12400/vendor.9b5136f2335ece1032af.js:59:57315)
    at Kn (http://10.117.142.216:12400/vendor.9b5136f2335ece1032af.js:59:57623)
    at fr (http://10.117.142.216:12400/vendor.9b5136f2335ece1032af.js:59:61005)
    at ur (http://10.117.142.216:12400/vendor.9b5136f2335ece1032af.js:59:60514)
    at sr (http://10.117.142.216:12400/vendor.9b5136f2335ece1032af.js:59:60340)
    at ir (http://10.117.142.216:12400/vendor.9b5136f2335ece1032af.js:59:59712)
    at Jn (http://10.117.142.216:12400/vendor.9b5136f2335ece1032af.js:59:59071)
    at Object.enqueueSetState (http://10.117.142.216:12400/vendor.9b5136f2335ece1032af.js:67:22728)
    at l.i.setState (http://10.117.142.216:12400/vendor.9b5136f2335ece1032af.js:59:784)
    at l.onStateChange (http://10.117.142.216:12400/vendor.9b5136f2335ece1032af.js:41:224820)
    at Object.notify (http://10.117.142.216:12400/vendor.9b5136f2335ece1032af.js:67:59059)
    at e.notifyNestedSubs (http://10.117.142.216:12400/vendor.9b5136f2335ece1032af.js:67:59571)
    at l.onStateChange (http://10.117.142.216:12400/vendor.9b5136f2335ece1032af.js:41:224838)

```

I'm also getting this error...

```auto
{'errors': [{'code': 'root.invalid_json_request',
             'fields': ['plan.elasticsearch'],
             'message': 'JSON request does not comply with schema: [Object is '
                        "missing required member 'elasticsearch']"}]}

```

when I omit elasticsearch from the plan, even though it isn't required according to the API reference at [https://www.elastic.co/guide/en/cloud-enterprise/current/ElasticsearchClusterPlan.html](https://www.elastic.co/guide/en/cloud-enterprise/current/ElasticsearchClusterPlan.html) so not sure if that should be required in the docs or I'm just misunderstanding something somewhere ( more likely 🙂 )

I'm on 2.0.0 if that makes a difference too.

Thanks  
James

---

<div class="post-metadata">

**Author:** ![gmarz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gmarz/32/22178_2.png) [@gmarz](https://discuss.elastic.co/u/gmarz)\
**Post date:** [October 4, 2018, 7:24pm UTC](https://discuss.elastic.co/t/creating-cluster-with-the-api/151063/2 "2018-10-04T19:24:35Z")

</div>

Hey @JamesNotJamez

There are a few issues here:

1. The plan you are submitting is missing the `size` ([TopologySize](https://www.elastic.co/guide/en/cloud-enterprise/current/TopologySize.html)) field in the cluster topology elements.

Try this instead (adjusting the `value`s as necessary):

```json
{
	"kibana": {
		"cluster_name": "py_kib",
		"plan": {
			"cluster_topology": [
				{
					"instance_configuration_id": "kibana",
					"zone_count": 1,
					"size": {
						"value": 1024,
						"resource": "memory"
					}
				}
			],
			"kibana": {
				"version": "6.4.0"
			},
			"transient": {},
			"zone_count": 2
		}
	},
	"plan": {
		"cluster_topology": [
			{
				"instance_configuration_id": "data.default",
				"node_type": {
					"data": true,
					"ingest": true,
					"master": true,
					"ml": false
				},
				"zone_count": 1,
				"size": {
					"value": 1024,
					"resource": "memory"
				}
			},
			{
				"instance_configuration_id": "data.highstorage",
				"node_type": {
					"data": true,
					"ingest": true,
					"master": false,
					"ml": false
				},
				"zone_count": 1,
				"size": {
					"value": 1024,
					"resource": "memory"
				}
			}
		],
		"elasticsearch": {
			"curation": {
				"from_instance_configuration_id": "data.default",
				"to_instance_configuration_id": "data.highstorage"
			},
			"version": "6.4.0"
		},
		"tiebreaker_topology": {
			"memory_per_node": 1024
		}
	},
	"settings": {
		"curation": {
			"specs": []
		}
	}
}

```

1. The API gladly accepts this plan, because it is "partially" a valid way to downscale (terminate) a deployment. The issue that you've run into is a bug that has surfaced due to this partially correct plan not being properly handled by the UI. I've filed an issue for our team to fix -- but applying the corrected plan above should avoid this altogether.

2. `plan.elasticsearch` is definitely a required field (as the error indicates). This is simply a bug in our documentation -- which we'll also fix, so thank you for pointing that out!

Let me know if this helps.

Greg

---

<div class="post-metadata">

**Author:** ![JamesNotJamez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jamesnotjamez/32/45736_2.png) [@JamesNotJamez](https://discuss.elastic.co/u/JamesNotJamez)\
**Post date:** [October 5, 2018, 9:53am UTC](https://discuss.elastic.co/t/creating-cluster-with-the-api/151063/3 "2018-10-05T09:53:51Z")

</div>

Thanks Greg, that's got it working now 😁

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 19, 2018, 9:53am UTC](https://discuss.elastic.co/t/creating-cluster-with-the-api/151063/4 "2018-10-19T09:53:53Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
