> For the complete documentation index, see [llms.txt](https://docs.fieldmotion.com/fieldmotion-api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fieldmotion.com/fieldmotion-api-docs/availability/_save.md).

# \_save

Creates or edits an Availability.

### Parameters

#### id

The ID of the Availability. This parameter is not used if creating a new Availability.

#### obj\_type

The sort of object which this Availability will affect, being a Company, Department, Role or User.

* company
* department
* role
* user

#### event\_type

The type of event in relation to the Availability, can be one of the following:

* absence
* annual\_leave
* sick\_leave
* unpaid\_leave
* public\_holiday
* company\_holiday
* unavailable
* available\_override

#### availability

Whether this counts as a period of Availability or Unavailability. (0=Unavailable, 1=Available)

#### status

The Status of the Availability:\
0 = Pending\
1 = Approved\
2 = Rejected\
3 = Cancelled

#### name

The name of this Availability.

#### start\_e

An epoch time format of the start date for this Availability.

#### end\_e

An epoch time format of the end date for this Availability.

#### all\_day

Whether the Availability counts as all day or not. (0 = No, 1 = Yes)

#### paid

Whether the Availability will be paid time or not. (0 = No, 1 = Yes)

#### notes

The notes which will be set for this Availability.

#### obj\_id

The ID of the object in relation to the "obj\_type" parameter, e.g a User's ID.

### Example

```
FM_api('Availability_save',[
	  'id'=>'30001',
		'obj_type'=>'role',
		'event_type'=>'available_override',
		'availability'=>'1',
		'status'=>'0',
		'name'=>'test availability',
		'start_e'=>'1781823600',
		'end_e'=>'1781910000',
		'all_day'=>'1',
		'paid'=>'1',
		'notes'=>'test availability',
		'obj_id'=>'1234'
	]
);
```

### Result

```
{"ok":1,"id":30001,"event":{"id":30001,"obj_type":"user","obj_id":113747,"event_type":"available_override","availability":1,"status":0,"status_name":"pending","name":"test availability","start_e":1781823600,"end_e":1781910000,"all_day":1,"paid":1,"requested_by":113747,"approved_by":0,"approved_at":0,"notes":"test availability","meta":[],"cdate":1781616047,"last_edited":1781690481,"created_by":113747}}
```

#### On Failure

If the "id" parameter is set but does not match an existing Availability:

```
{"error":"availability event not found"}
```

If the target set by "obj\_type" and "obj\_id" does not exist:

```
{"error":"target does not exist"}
```
