# Suspend API Not Working

**URL:** https://meta.discourse.org/t/suspend-api-not-working/72375
**Category:** Development
**Tags:** rest-api
**Created:** [October 18, 2017, 8:47pm UTC](https://meta.discourse.org/t/suspend-api-not-working/72375 "2017-10-18T20:47:35Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![Geoffrey\_Challen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/geoffrey_challen/32/119637_2.png) [@Geoffrey\_Challen](https://meta.discourse.org/u/Geoffrey_Challen)
#### Post date: [October 18, 2017, 8:47pm UTC](https://meta.discourse.org/t/suspend-api-not-working/72375/1 "2017-10-18T20:47:35Z")

</div>

This is related to [API not returning suspended fields properly - #6 by eviltrout](https://meta.discourse.org/t/api-not-returning-suspended-fields-properly/71850/6). Tagging @eviltrout since they seem to own this codebase.

Now it seems the issue is that the suspend API is not working properly. Here’s the code that we’ve been using for several months:

```javascript
client.put('admin/users/' + user.id + '/suspend?' + 
  queryString.stringify({
    api_username: passwords.discourse.username,
    api_key: passwords.discourse.key
  }), {
    duration: 99999,
    reason: 'No longer in CS 125.'
  }, function (err, res, body) {
    should.not.exist(err);
    res.statusCode.should.equal(200);
    return callback();
});   

```

Again, this worked fairly recently. But now when we run it: (a) the suspended count shown on the user page goes up by one, but (b) the user is actually not suspended correctly. They don’t show as suspended in the UI, and return as active the next time we pull the users list.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [October 18, 2017, 10:20pm UTC](https://meta.discourse.org/t/suspend-api-not-working/72375/2 "2017-10-18T22:20:05Z")

</div>

Does it work when you suspend the user using the UI?

If it does, then look at the request made when you click the button.  
If it doesn’t, then it’s a 🐛.

---

<div class="post-metadata">

### Author: ![Geoffrey\_Challen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/geoffrey_challen/32/119637_2.png) [@Geoffrey\_Challen](https://meta.discourse.org/u/Geoffrey_Challen)
#### Post date: [October 19, 2017, 12:54am UTC](https://meta.discourse.org/t/suspend-api-not-working/72375/3 "2017-10-19T00:54:27Z")

</div>

I understand that you can reverse the API. But this call [is documented](http://docs.discourse.org/#tag/Admin%2Fpaths%2F~1admin~1users~1%7Bid%7D~1suspend%2Fput). So either the documentation is wrong, or it’s not working as expected.

Again: this worked quite recently.

---

<div class="post-metadata">

### Author: ![awlogan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awlogan/32/62208_2.png) [@awlogan](https://meta.discourse.org/u/awlogan)
#### Post date: [October 19, 2017, 1:21am UTC](https://meta.discourse.org/t/suspend-api-not-working/72375/4 "2017-10-19T01:21:21Z")

</div>

It seems like there was an update to the suspend dialog. I can now pull down an option that says forever vs. the 9999 days use, as well as an email reason for the suspension. I don’t remember seeing that before, but I could be wrong as I only suspend people when they leave the company (so far). I would expect that the API would need to change, probably the doc hasn’t caught up to it.

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [October 19, 2017, 1:26am UTC](https://meta.discourse.org/t/suspend-api-not-working/72375/5 "2017-10-19T01:26:40Z")

</div>

Suspend was improved recently to provide more options, so it is very possible that the documentation is out of date.

---

<div class="post-metadata">

### Author: ![Geoffrey\_Challen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/geoffrey_challen/32/119637_2.png) [@Geoffrey\_Challen](https://meta.discourse.org/u/Geoffrey_Challen)
#### Post date: [October 19, 2017, 1:26pm UTC](https://meta.discourse.org/t/suspend-api-not-working/72375/6 "2017-10-19T13:26:17Z")

</div>

OK, thanks for all the help. It threw me off a bit that the new suspend UI is using a form, rather than posting JSON, but posting the form contents seems to work fine.

---

<div class="post-metadata">

### Author: ![huberfe](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/huberfe/32/87242_2.png) [@huberfe](https://meta.discourse.org/u/huberfe)
#### Post date: [January 12, 2018, 3:48pm UTC](https://meta.discourse.org/t/suspend-api-not-working/72375/7 "2018-01-12T15:48:19Z")

</div>

@jomaxro is it able to have the ‘forever’ option via api as well?

> **[Discourse API Docs](https://docs.discourse.org/#tag/Admin%2Fpaths%2F~1admin~1users~1%7Bid%7D~1suspend%2Fput)**

what would we need to put into the request?

```plaintext
{
  "suspend_until": "string",
  "reason": "string"
}
```

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [January 12, 2018, 4:27pm UTC](https://meta.discourse.org/t/suspend-api-not-working/72375/8 "2018-01-12T16:27:45Z")

</div>

I would assume it’s possible, but I’m not an API expert. @eviltrout did the recent suspend improvements, he should be able to confirm.

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [January 12, 2018, 7:56pm UTC](https://meta.discourse.org/t/suspend-api-not-working/72375/9 "2018-01-12T19:56:31Z")

</div>

To do it forever, just pass a date about 1000 years into the future. If it’s that far away we display “Forever”.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [January 12, 2018, 8:45pm UTC](https://meta.discourse.org/t/suspend-api-not-working/72375/10 "2018-01-12T20:45:21Z")

</div>

> [@eviltrout](#):
>
> about 1000 years into the future

I like to think medical advances will someday lengthen lifespan. Pessimist that I am, I don’t hold hope that I’ll see a day of the year 2291 (five nines, 99999 days)

[![](https://global.discourse-cdn.com/meta/original/4X/6/9/3/693828203c52c0cdfca95a3c9b4a0d1f8e8e1beb.jpeg "Moody Blues: 22000 Days") ](https://www.youtube.com/watch?v=gbLCP9ENemI)

---

<div class="post-metadata">

### Author: ![sarahann](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sarahann/32/96703_2.png) [@sarahann](https://meta.discourse.org/u/sarahann)
#### Post date: [June 22, 2018, 5:01pm UTC](https://meta.discourse.org/t/suspend-api-not-working/72375/11 "2018-06-22T17:01:48Z")

</div>

Is there a specific format for the date?

Seconds since Jan 1st? yyyyMMDDhhssmm?

Do we assume its UTC time?

I am able to suspend a user, but it seems to always be in the past. I am assuming the date I am trying to pass is wrong.

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [June 22, 2018, 5:53pm UTC](https://meta.discourse.org/t/suspend-api-not-working/72375/12 "2018-06-22T17:53:31Z")

</div>

You can use just `yyyy-MM-DD` format for `suspend_until`.

So ‘2018-07-22’ would suspend them for one month (from today).

If you need something more granular (hours and minutes) you can use this format:

```
2018-07-22+08:00-06:00

```

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [January 7, 2021, 11:45am UTC](https://meta.discourse.org/t/suspend-api-not-working/72375/13 "2021-01-07T11:45:13Z")

</div>



---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [January 7, 2021, 3:14pm UTC](https://meta.discourse.org/t/suspend-api-not-working/72375/14 "2021-01-07T15:14:48Z")

</div>


