POST /sites/$site/headers/mine

Set the custom header options for a site.

Resource Information

   
Method POST
URL https://public-api.wordpress.com/rest/v1.1/sites/$site/headers/mine
Requires authentication? Yes

Method Parameters

Parameter Type Description
$site (int|string) Site ID or domain.

Query Parameters

Parameter Type Description
context (string)
display:
(default) Formats the output as HTML for display. Shortcodes are parsed, paragraph tags are added, etc..
edit:
Formats the output for editing. Shortcodes are left unparsed, significant whitespace is kept, etc..
http_envelope (bool)
false:
(default)
true:
Some environments (like in-browser JavaScript or Flash) block or divert responses with a non-200 HTTP status code. Setting this parameter will force the HTTP status code to always be 200. The JSON response is wrapped in an "envelope" containing the "real" HTTP status code and headers.
pretty (bool)
false:
(default)
true:
Output pretty JSON
meta (string) Optional. Loads data from the endpoints found in the 'meta' part of the response. Comma-separated list. Example: meta=site,likes
fields (string) Optional. Returns specified fields only. Comma-separated list. Example: fields=ID,title
callback (string) An optional JSONP callback function.

Request Parameters

Parameter Type Description
remove (bool) Optional. True to remove the header image.
reset (bool) Optional. True to reset the header image to the default.
random_default (bool) Optional. True to set header to random default image.
random_uploaded (bool) Optional. True to set header to random uploaded image.
text_color (string) Optional. The header text color.
reset_text_color (bool) Optional. True to reset the header text color to the default.
url (string) Optional. A url of a custom header to set. Requires attachment_id, width, height.
attachment_id (int|string) Optional. The attachment ID of the image. Requires url, width, height.
width (int) Optional. The width of the image. Requires url, attachment_id.
height (int) Optional. The height of the image. Requires url, attachment_id.

Response Parameters

Parameter Type Description
random_default (bool) True if the random_default setting is set.
random_uploaded (bool) True if the random_uploaded setting is set.
text_color (string) The header text color.
url (string) The url of the current header image if one is set (does not include default).
width (int) The width of the current header image if one is set.
height (int) The height of the current header image if one is set.
defaults (string)
url:
(string) The url of the default header image if one exists.
text_color:
(string) The default header text color.
header_text:
(bool) True if the header_text default setting is set.
random_default:
(bool) True if the random_default setting is the default.

Resource Errors

These are the possible errors returned by this endpoint.

HTTP Code Error Identifier Error Message
403 unauthorized This user is not authorized to modify the header on this blog
501 not_implemented That feature is not implemented
400 invalid_data The data you provided was not accurate.
400 missing_data The data you provided was not accurate.
400 no_data No data was provided.
403 unauthorized User cannot access this private blog.
403 unauthorized User cannot access this restricted blog

Example

curl \
 -H 'authorization: Bearer YOUR_API_TOKEN' \
 --data-urlencode 'url=https://restapitests.files.wordpress.com/2014/10/blank348.png' \
 --data-urlencode 'attachment_id=7753' \
 --data-urlencode 'width=1' \
 --data-urlencode 'height=1' \
 'https://public-api.wordpress.com/rest/v1/sites/2916284/headers/mine'
<?php
$options  = array (
  'http' => 
  array (
    'ignore_errors' => true,
    'method' => 'POST',
    'header' => 
    array (
      0 => 'authorization: Bearer YOUR_API_TOKEN',
      1 => 'Content-Type: application/x-www-form-urlencoded',
    ),
    'content' => 
     http_build_query(  array (
        'url' => 'https://restapitests.files.wordpress.com/2014/10/blank348.png',
        'attachment_id' => '7753',
        'width' => '1',
        'height' => '1',
      )),
  ),
);

$context  = stream_context_create( $options );
$response = file_get_contents(
	'https://public-api.wordpress.com/rest/v1/sites/2916284/headers/mine',
	false,
	$context
);
$response = json_decode( $response );
?>

Response

{
    "url": "https:\/\/restapitests.files.wordpress.com\/2014\/10\/blank348.png",
    "width": 1000,
    "height": 288,
    "text_color": "000",
    "defaults": {
        "url": "",
        "header_text": false,
        "text_color": "000",
        "random_default": true
    }
}