= CoAP Component
:doctitle: CoAP
:shortname: coap
:artifactid: camel-coap
:description: Send and receive messages to/from COAP capable devices.
:since: 2.16
:supportlevel: Stable
:component-header: Both producer and consumer are supported
//Manually maintained attributes
:camel-spring-boot-name: coap

*Since Camel {since}*

*{component-header}*

Camel-CoAP is an http://camel.apache.org/[Apache Camel] component that
allows you to work with CoAP, a lightweight REST-type protocol for machine-to-machine operation. 
http://coap.technology/[CoAP], Constrained Application Protocol is a specialized web transfer protocol 
for use with constrained nodes and constrained networks and it is based on RFC 7252.

Camel supports the DTLS, TCP and TLS protocols via the following URI schemes:

[width="100%",cols="2,5",options="header"]
|===
| Scheme | Protocol
| coap   | UDP
| coaps  | UDP + DTLS
| coap+tcp | TCP
| coaps+tcp | TCP + TLS
|===

There are a number of different configuration options to configure TLS. For both DTLS (the "coaps" uri scheme)
and TCP + TLS (the "coaps+tcp" uri scheme), it is possible to use a "sslContextParameters" parameter, from 
which the camel-coap component will extract the required truststore / keystores etc to set up TLS. In addition,
the DTLS protocol supports two alternative configuration mechanisms. To use a pre-shared key, configure a 
pskStore, and to work with raw public keys, configure privateKey + publicKey objects.

Maven users will need to add the following dependency to their pom.xml
for this component:

[source,xml]
---------------------------------------------------------
<dependency>
 <groupId>org.apache.camel</groupId>
 <artifactId>camel-coap</artifactId>
 <version>x.x.x</version>
 <!-- use the same version as your Camel core version -->
</dependency>
---------------------------------------------------------


// component-configure options: START

// component-configure options: END

// component options: START
include::partial$component-configure-options.adoc[]
include::partial$component-endpoint-options.adoc[]
// component options: END

// endpoint options: START

// endpoint options: END


== Message Headers

[width="100%",cols="10%,20%,70%",options="header",]
|=======================================================================
|Name |Type |Description

|`CamelCoapMethod` |`String` |The request method that the CoAP producer should use when calling the target CoAP
server URI. Valid options are DELETE, GET, PING, POST & PUT.

|`CamelCoapResponseCode` |`String` |The CoAP response code sent by the external server. See RFC 7252 for details
of what each code means.

|`CamelCoapUri` |`String` |The URI of a CoAP server to call. Will override any existing URI configured directly on the endpoint.
|=======================================================================

=== Configuring the CoAP producer request method

The following rules determine which request method the CoAP producer will use to invoke the target URI:

 1. The value of the `CamelCoapMethod` header
 2. **GET** if a query string is provided on the target CoAP server URI.
 3. **POST** if the message exchange body is not null.
 4. **GET** otherwise.


include::spring-boot:partial$starter.adoc[]
