Website logo

Withdraw an auction or classified

Withdraw a live listing from Trade Me, either because it sold or because it did not sell.

Authentication: requires an OAuth access token with the MyTradeMeWrite permission (the same permission for every category). The listing must belong to the authenticated member.

Which listings can be withdrawn: only live listings. A listing that has already closed is rejected with "This listing has already closed." or "You can only withdraw live listings."; a listing that cannot be found with "Could not find {id}"; and a listing owned by another member with "Member {member id} does not own listing" (all HTTP 200 with Success false). An auction with less than one hour to run cannot be withdrawn ("Cannot withdraw an auction with less than one hour to run."), and a listing in a category where listings cannot be sold cannot be withdrawn as sold ("Listings in this category are unsellable, so you cannot specify it was sold."). Withdrawing a listing may incur a withdrawal fee or a success fee; call the withdraw fees API first to find out. For a multi-variant listing, every variant that is still open is withdrawn.

Request errors (HTTP 200, Success false, with these messages in Description): "If the listing was sold, you must specify a price.", "If the listing was not sold, you must specify the reason you are withdrawing.", "The reason you give must be 255 characters or less." and "The price must be greater than or equal to 0.".

Finding out why a call failed. Business-rule failures (for example a validation message, a listing you do not own, or a listing in the wrong state) are returned with HTTP 200 and a ListingResponse whose Success is false and whose Description holds the reason; check Success, not only the HTTP status. Several validation messages are joined with new lines in Description, and each is prefixed with the attribute name as "For {attribute name} : {message}" when the message relates to an attribute. A request that cannot be processed at all (for example malformed JSON) is returned with HTTP 400 and an error body containing Request (the URL called) and ErrorDescription (the message), and, for some errors, Error (with Code, UserDescription and DeveloperDescription) and an Errors list when there is more than one. A missing or insufficient OAuth token returns HTTP 401 with an ErrorDescription naming the permission required. Any unexpected server error returns HTTP 500 with a generic message.

URL: https://api.trademe.co.nz/v1/Selling/Withdraw.{file_format}
HTTP Method: POST
Requires Authentication? Yes
Permission Required: MyTradeMeWrite: Maintain your watchlist, answer questions and post comments.
Supported Formats: XML, JSON
Rate Limited? Yes

URL parameters

file_format Enumeration (required) The format of the response.
xml Serialize responses into XML.
json Serialize responses into JSON.

POST Data

<WithdrawRequest>

ListingId Integer (required)

The ID of the listing to withdraw, relist or extend. For a relist this is the ID of the closed listing, not of the new listing that the relist creates. Required.

ReturnListingDetails Boolean (optional)

Optional, default false. Set to true to have the full listing details returned in the Listing field of the response when the call succeeds.

Type Enumeration (required)

Whether the listing sold or not (serialised as "Type"). Required. If ListingWasSold, SalePrice is required and Reason is ignored; if ListingWasNotSold, Reason is required and SalePrice is ignored.

ListingWasSold 1

The item was sold.

ListingWasNotSold 2

The item didn't sell.

Reason String (optional)

The reason for withdrawing the listing. Required when the listing did not sell; ignored when it sold. Max 255 characters.

SalePrice Number (optional)

The amount the listing sold for, in NZD. Required (0 or more) when the listing sold; ignored when it did not sell.

Returns

<ListingResponse>

A ListingResponse. When Success is true, ListingId is the ID of the withdrawn listing (unchanged) and Description reads "{id} withdrawn". When Success is false, Description explains why and the listing was not withdrawn.

Success Boolean

Indicates whether the operation was successful.

Description String or null

The description of the error, if the operation failed.

ListingId Integer

The ID of the listing the call acted on. For a create or a relist this is the ID of the new listing; for an edit, extend or withdraw it is the listing you supplied. Omitted on some failures.

Listing <ListedItemDetail> or null

The state of the listing, after the listing operation has successfully completed. This field is only present if the ReturnListingDetails parameter is true and the operation was successful. This field will also be missing if there was an error retrieving the listing details. For more information on this field, see the documentation for the listing details API.

(This type is defined elsewhere)

Example XML Request (switch to JSON)

<WithdrawRequest xmlns="http://api.trademe.co.nz/v1">
  <ListingId>123</ListingId>
  <ReturnListingDetails>false</ReturnListingDetails>
  <Type>ListingWasSold</Type>
  <Reason>ABC</Reason>
  <SalePrice>123.0</SalePrice>
</WithdrawRequest>

Example JSON Request (switch to XML)

{
  "ListingId": 123,
  "ReturnListingDetails": false,
  "Type": 1,
  "Reason": "ABC",
  "SalePrice": 123.0
}

Example XML Response (switch to JSON)

<ListingResponse xmlns="http://api.trademe.co.nz/v1">
  <Success>false</Success>
  <Description>ABC</Description>
  <ListingId>123</ListingId>
  <Listing> ... </Listing>
</ListingResponse>

Example JSON Response (switch to XML)

{
  "Success": false,
  "Description": "ABC",
  "ListingId": 123,
  "Listing": { ... }
}