# \_save

Creates or modifies a Geofence.

### Parameters

#### data

An array of several aspects of the chosen Geofence:\
name\
max\_lat\
min\_lat\
max\_lng\
min\_lng\
points (radius, type)\
last\_edited\
cdate

#### name

The name assigned to the created/saved Geofence

### Example

This will set the name of a Geofence with the ID of 2 to 'Test', give it a radius of 250 in a circle shape, and center it around Forthill Park in Enniskillen

<pre><code>FM_api(
    'Geofence_save',[
        'data' => '{"id":2,"max_lat":54.347115,"min_lat":54.343517,
        "max_lng":-7.6295705,"min_lng":-7.635742,"points":{"radius":250,
<strong>        "type":"circle"},"name":"Test","meta":[],"last_edited":1679828787,
</strong>        "cdate":1679828658}'
    ]
);
</code></pre>

### Results

#### On Success

```
{"ok":1,"id":2}
```

#### On Failure

If there is no data variable requested or the requested variable is not formatted correctly:

```
{"error":"missing or invalid parameter: data"}
```

If a new name being given to the Geofence is higher than 50 characters

```
{"error":"name too long. max length 50"}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.fieldmotion.com/fieldmotion-api-docs/geofence/_save.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
