---
title: "Calendar export (ICS) — Appointments for Laravel | Roundly"
description: "Export one appointment or a whole schedule as RFC 5545 .ics text — status mapping, escaping, GEO, ORGANIZER and ATTENDEE lines."
url: https://roundly-consulting.com/open-source/docs/appointments-for-laravel/calendar-export
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Appointments for Laravel](https://roundly-consulting.com/open-source/docs/appointments-for-laravel.md)

# Calendar export (ICS)

Generate RFC 5545 calendar text for one appointment or a collection. The package stays HTTP-free — it returns a string and you decide how to deliver it:

```php
use RoundlyConsulting\Appointments\Facades\Appointments;

$ics = Appointments::for($appointment)->ics();                        // one event — or $appointment->toIcs()
$feed = Appointments::ics($user->appointments()->upcoming()->get());  // one VCALENDAR, many VEVENTs

return response($feed, 200, [
    'Content-Type' => 'text/calendar; charset=utf-8',
    'Content-Disposition' => 'attachment; filename="appointments.ics"',
]);
```

## Sample output

```
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Roundly Consulting//Appointments for Laravel//EN
CALSCALE:GREGORIAN
BEGIN:VEVENT
UID:3f2c9a7e-5b1d-4c8e-9a6f-0d4e2b7c1a95@example.com
DTSTAMP:20260615T120000Z
DTSTART:20260701T090000Z
DTEND:20260701T100000Z
SUMMARY:Clinic visit
STATUS:TENTATIVE
DESCRIPTION:Bring your previous test results
LOCATION:Clinic A
GEO:51.5074;-0.1278
ORGANIZER;CN=Front desk:mailto:desk@example.com
ATTENDEE;CN=Alex Example:mailto:alex@example.com
END:VEVENT
END:VCALENDAR
```

## What goes into each event

| Property | Source |
| --- | --- |
| `UID` | The appointment’s stored random uuid at your app.url host (…@example.com) — unique across apps and stable across a re-seeded database. |
| `DTSTART / DTEND` | starts\_at / ends\_at in UTC; a missing end is derived from the duration. |
| `SUMMARY` | name. |
| `DESCRIPTION` | description, when set. |
| `STATUS` | TENTATIVE for pending; CONFIRMED for confirmed and completed; CANCELLED for cancelled, declined and no-show. |
| `LOCATION` | The location column, falling back to meta.location. |
| `GEO` | latitude;longitude, when coordinates are set. |
| `ORGANIZER` | The appointment’s primary email contact; CN is the contact’s name, else its label. |
| `ATTENDEE` | One per participant whose model has a primary email; CN is the model’s name attribute. |

Participants without a primary email are left out: an ATTENDEE must be a calendar address — in practice mailto: — and calendar clients have nothing to act on without one. Add HasContacts to participant models to include them (see Guest contacts).

## Escaping and folding

Text values are escaped per RFC 5545 §3.3.11: any line break — a textarea’s CRLF, a lone CR or LF — becomes one escaped \\n; backslashes, semicolons and commas are backslash-escaped; other control characters except tab are dropped. CN values lose double quotes and control characters and are quoted when they contain a colon, semicolon or comma. Long lines fold at 75 octets without splitting a multi-byte UTF-8 character, and every line ends in CRLF.

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/appointments-for-laravel.md)
