# Specify retry attempts at enqueue

**URL:** https://discuss.hangfire.io/t/specify-retry-attempts-at-enqueue/11429
**Category:** question
**Created:** [May 20, 2026, 9:55am UTC](https://discuss.hangfire.io/t/specify-retry-attempts-at-enqueue/11429 "2026-05-20T09:55:57Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![petermorlion](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/petermorlion/32/4081_2.png) [@petermorlion](https://discuss.hangfire.io/u/petermorlion)
#### Post date: [May 20, 2026, 9:55am UTC](https://discuss.hangfire.io/t/specify-retry-attempts-at-enqueue/11429/1 "2026-05-20T09:55:57Z")

</div>

I’m looking for a way to specify the retry attempts when I enqueue my job. I know it’s possible with an attribute on the job class, but I need it to be variable, i.e. I don’t know at compile time what the number of retries will be.

I’ve tried this:

```auto
var client = new BackgroundJobClient(JobStorage.Current);
client.RetryAttempts = retryAttempts;
client.Enqueue<MyJob>(x => x.DoWork());

```

And this:

```auto
var filters = new JobFilterCollection();

foreach (var filter in GlobalJobFilters.Filters)
{
    filters.Add(filter.Instance);
}

filters.Add(new AutomaticRetryAttribute { Attempts = retryAttempts });

var client = new BackgroundJobClient(JobStorage.Current, filters);

client.Enqueue<MyJob>(x => x.DoWork());

```

But it still seems to retry 10 times. So what is the best way to specify the number of retry attempts at the moment we enqueue our job?
