V4.1 HTTP API change stream MaxAge

Hi there,
I’m completely new to EventStore, I’ve a number of streams that have events over 3 years old. I was wondering how I’d go about changing the MaxAge of these streams via the HTTP API?

I’ve tried to query the stream for existing metadata using the following curl command and it doesn’t return anything other than “OK”:

curl -i -H “Accept:application/vnd.eventstore.atom+json” “https://url/streams/metadata” --user username:password

Any advice would be gratefully received!

I don’t remember the API, especially for v4, but you can do those operations (read stream meta and set the max age) in the web UI and check in the browser dev tools what API calls the UI will make.

1 Like

Thanks for getting back to me! Is there somewhere specific in the UI you can set this from?

The stream browser does appear to have a button called “metadata”. This takes you to this screen:

The “Add new like this” button allows you to add an event to the stream with both data/metadata but not modify the metadata of the stream itself.

Yeah, you are right. It’s weird, I thought it is available. I know how to do it via the client, but not via the HTTP API. I can check tomorrow.

1 Like

Thanks really appreciate it!

Sorry, I wasn’t able to check it yet, but it’s in my todo list.

Great! Any joy yet? :slight_smile:

I followed the docs and executed this command to get the stream metadata:

http://127.0.0.1:2113/streams/Booking-BookingId6f3999b6-e6ca-4079-9e01-acd23dd646ac/metadata

Here, Booking-BookingId6f3999b6-e6ca-4079-9e01-acd23dd646ac is the stream name from my test instance (running locally, insecure).

I got an empty JSON object back as expected.

To update the max age you need to append an event to the metadata stream (make a POST request to the same URL) with the following payload:

[
    {
        "eventId": some_guid,
        "eventType": "$metadata",
        "data": {
             "$maxAge": 86400
        }
    }
]

There, 86400 is one day in seconds.

That’s how the meta stream looks like after the update: