> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superoffice.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create an appointment using services

> Create an appointment using NetServer services

This example shows you how to create an appointment using [NetServer services][1]. The new appointment will be added to the diary of associate 103 by the logged-in user is SAL0.

## Code

```csharp theme={null}
using SuperOffice.CRM.Services;
using SuperOffice;

using(SoSession newSession = SoSession.Authenticate("SAL0", ""))
{
  //Create an appointment agent
  using(AppointmentAgent appointmentAgent = new AppointmentAgent())
  {
    //Create an appointment entity through the appointment agent
    AppointmentEntity myAppointment = appointmentAgent.CreateDefaultAppointmentEntityByTypeAndAssociate(SuperOffice.Data.TaskType.Appointment, 103);

    //Assign values to some of the properties of the appointment
    myAppointment.Location = "5th Floor,Seminar Room";
    myAppointment.AlarmLeadTime = TimeSpan.FromMinutes(10.00);
    myAppointment.StartDate = DateTime.Today.AddDays(5);
    myAppointment.EndDate = DateTime.Today.AddDays(5);
    myAppointment.HasAlarm = true;
    myAppointment.Description = "this is a new appointment";
    myAppointment.AlldayEvent = true;

    //Save the newly created appointment in the database
    appointmentAgent.SaveAppointmentEntity(myAppointment);
  }
}
```

## Walk-through

In the example, we create an `Appointment` using the [CreateDefaultAppointmentEntityByTypeAndAssociate][2] method exposed through the agent. The method requires 2 parameters:

* the type of the requested task
* the `AssociateID` - the ID for whom the appointment should be created

[1]: ../../index

[2]: ../../../reference/restful/agent/Appointment_Agent/v1AppointmentAgent_CreateDefaultAppointmentEntityByTypeAndAssociate


## Related topics

- [How to create a recurring appointment (services)](/en/api/web-services/howto/diary/create-recurring-appointment-services.md)
- [How to create a user-defined field using the web services API](/en/api/web-services/howto/custom-objects/rest-create-udef-field.md)
- [How to create an invitation (services)](/en/api/web-services/howto/diary/create-invitation-services.md)
- [Using dialogs in triggers](/en/automation/crmscript/tutorials/using-dialogs-in-triggers.md)
- [Create Default Recurrence By Date](/en/api/reference/restful/agent/appointment_agent/create-default-recurrence-by-date.md)
- [SuperOffice.WebApi.Agents.AppointmentAgent](/en/api/reference/webapi/SuperOffice.WebApi.Agents.AppointmentAgent.md)
