= CoAP Component
:doctitle: CoAP
:shortname: coap
:artifactid: camel-coap
:description: Send and receive messages to/from CoAP (Constrained Application Protocol) capable devices.
:since: 2.16
:supportlevel: Stable
:tabs-sync-option:
: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.

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

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

== Usage

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.


=== 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. `GE` 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[]
