Alpaca.Markets.RestClientErrorException: Forbidden

using System;

using Alpaca.Markets;

using System.Threading.Tasks;

namespace AlpacaExample


internal static class Program


    private const String KEY_ID = "PKIB1.........8LEBFS";

    private const String SECRET_KEY = "x2ob..........2hw";

    public static async Task Main()


        var client = Environments.Paper

            .GetAlpacaTradingClient(new SecretKey(KEY_ID, SECRET_KEY));

        var clock = await client.GetClockAsync();

        if (clock != null)



                "Timestamp: {0}, NextOpen: {1}, NextClose: {2}",

                clock.TimestampUtc, clock.NextOpenUtc, clock.NextCloseUtc);





Unhandled exception. Alpaca.Markets.RestClientErrorException: Forbidden
at Alpaca.Markets.HttpResponseMethodExtensions.DeserializeAsync[TApi,TJson](HttpResponseMessage response)
at Alpaca.Markets.HttpResponseMethodExtensions.DeserializeAsync[TApi,TJson](HttpResponseMessage response)
at Alpaca.Markets.HttpClientExtensions.callAndDeserializeAsync[TApi,TJson](HttpMessageInvoker httpClient, HttpRequestMessage request, CancellationToken cancellationToken)
at Alpaca.Markets.HttpClientExtensions.callAndDeserializeAsync[TApi,TJson](HttpMessageInvoker httpClient, HttpMethod method, Uri endpointUri, CancellationToken cancellationToken)
at AlpacaExample.Program.Main() in C:\Users\taski\Documents\AlpacaMarkets_C#\Program.cs:line 18
at AlpacaExample.Program.()

Problem solved! please delete this post

Can you please help me to solve the same issue, what was the reason?


I generated first my KEY into my paper account. But afterwards, I reseted this account. Never thought about the KEY itself. It was also reseted.

So just generate a new KEY.

Thanks, what values do you use for fields:

private const String KEY_ID = “PKIB1…8LEBFS”;
private const String SECRET_KEY = “x2ob…2hw”;


Never mind already found that it is wrong place =)
One more time thanks for the help man.